If the query is like this
adventureworksEntities dbEntities = new adventureworksEntities();var query = from PC in dbEntities.productcategoryjoin PSC in dbEntities.productsubcategoryon PC.ProductCategoryID equals PSC.ProductSubcategoryIDselect new { PC.Name, PC.ModifiedDate, PSC.Name, PSC.ModifiedDate };
The compiler will throw the error,”An anonymous type cannot have multiple properties with the same name” .Because the compiler can’t able to find a proper Name.So we want to modify the query with alias name ,some thing like this.
var query = from PC in dbEntities.productcategoryjoin PSC in dbEntities.productsubcategoryon PC.ProductCategoryID equals PSC.ProductSubcategoryIDselect new { PCName1 = PC.Name, PCModifiedDate1 = PC.ModifiedDate, PSCName1 = PSC.Name, PSCModifiedDate1 = PSC.ModifiedDate };
0 comments:
Post a Comment