Version 2.5
I am trying to do a join to get the fields of two tables and past those to one Datatable
table 1 is Product
table 2 ProductTrapType
With the current code I get the data of the first table but not the field of the second.
definitely I know I am doing something wrong, is this the best way or there is other way to do it, and what am I doing wrong?.
Code:
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(ProductEntity.Relations.ProductTrapTypeEntityUsingTrapTypeFk, JoinHint.Left);
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection Product = new EntityCollection(new ProductEntityFactory());
adapter.FetchEntityCollection(Product, filter);
IEntityView2 ProductView = Product.DefaultView;
List<IEntityPropertyProjector> propertyProjectors = new List<IEntityPropertyProjector>();
propertyProjectors.Add(new EntityPropertyProjector(ProductFields.ProductName, "productname"));
propertyProjectors.Add(new EntityPropertyProjector(ProductFields.ProductId, "productid"));
propertyProjectors.Add(new EntityPropertyProjector(ProductFields.TrapTypeFk, "TrapType_FK"));
propertyProjectors.Add(new EntityPropertyProjector(ProductFields.SetoutMin, "setoutmin"));
propertyProjectors.Add(new EntityPropertyProjector(ProductFields.SetoutMax, "setoutmax"));
propertyProjectors.Add(new EntityPropertyProjector(ProductFields.StyleFk, "StyleFk"));
propertyProjectors.Add(new EntityPropertyProjector(ProductTrapTypeFields.Nametraptype, "Nametraptype"));// I can't get this
DataTable projectionResults = new DataTable();
ProductView.CreateProjection(propertyProjectors, projectionResults);
return projectionResults;