A projection is when you take the result of a LINQ query and "project" the results onto another object, anonymous or otherwise

The following types of projections are known to work

Project to an anonymous object
var result = from i in dStore.Query<TestItemForeignKeyWithString>()
			 join x in dStore.Query<TestItemPrimaryKey>() on i.FKeyField equals x.ID
			 select new
				{
					i.ID,
					x.Name,
					x.Date
				};			

Project to a defined object
var result = from i in dStore.Query<TestItemForeignKeyWithString>()
			 join x in dStore.Query<TestItemPrimaryKey>() on i.FKeyField equals x.ID
			 select new FooBar
				{
					ID = i.ID,
					Name = x.Name,
					Kitten = x.Date
				};


Project to a compound object (an object that has properties that are other objects)
var result = from i in dStore.Query<TestItemForeignKeyWithString>()
			 join x in dStore.Query<TestItemPrimaryKey>() on i.FKeyField equals x.ID
			 select new
			 {
				 i,
				 x
			 };

Last edited May 30, 2013 at 4:10 AM by iamkrillin, version 3

Comments

No comments yet.