public static IList <StormResult> ToResults(StormDataSet data, SchemaNavigator navigator, List <Origin> requests, OriginTree fromTree) { var root = navigator.GetEntity(data.root); var ranges = data.ObjectRanges; var primaryKeys = data.IdentityIndexes; var items = new Dictionary <EntityPath, Dictionary <object, StormResult> >(); var results = new List <StormResult>(); for (int i = 0; i < data.Count(); i++) { var ctx = new RecCtx() { Data = data, Index = i, PrimaryKeys = primaryKeys, Ranges = ranges, Root = root }; var(pk, r) = CreateResult(fromTree.root, ctx); if (!results.Any(x => x.PrimaryKey == pk)) { results.Add(r); } r = results.First(x => x.PrimaryKey == pk); CreateResultRelations(ctx, requests.Where(x => x.FullPath != fromTree.root.FullPath).ToList(), r); } return(results); }
private static (Storm, Schema.SchemaNavigator, StormDataSet) PrepareDataSet() { Storm s = StormDefine(); var nav = s.schema.GetNavigator(); var entity = nav.GetEntity("Test"); Origin fromNode = new Origin() { Alias = "A1", children = new List <Origin>(), Entity = entity, Edge = null, FullPath = new Schema.EntityPath("Test", "") }; var _idField = entity.entityFields.First(x => x.CodeName == "ID"); var _FirstName = entity.entityFields.First(x => x.CodeName == "FirstName"); var _LastName = entity.entityFields.First(x => x.CodeName == "LastName"); var _Email = entity.entityFields.First(x => x.CodeName == "Email"); var _Mobile = entity.entityFields.First(x => x.CodeName == "Mobile"); var _Phone = entity.entityFields.First(x => x.CodeName == "Phone"); var _Addre = entity.entityFields.First(x => x.CodeName == "Address"); StormDataSet data = new StormDataSet("Test"); List <SelectNode> nodes = new List <SelectNode>() { new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "ID"), EntityField = _idField }, new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "FirstName"), EntityField = _FirstName }, new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "LastName"), EntityField = _LastName }, new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "Email"), EntityField = _Email }, new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "Mobile"), EntityField = _Mobile }, new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "Phone"), EntityField = _Phone }, new SelectNode() { FromNode = fromNode, FullPath = new Schema.FieldPath("Test", "", "Address"), EntityField = _Addre } }; data.ReadData(new MonoEntityMockDataSources().GetReader(), nodes); return(s, nav, data); }
public void Should_Read_Projection_Result() { using (var con = storm.OpenConnection(PrepMethods.PrepareDB())) { StormDataSet r = con.Projection("Task") .Select("User.{FirstName, LastName}") .Select("TaskType") .Select("Completed") .Select("{DateStart, DateEnd}") .Select("Info.Field2") .Where(x => x["User.Email"].EqualTo.Val("*****@*****.**")) .Execute(); Assert.Equal(8, r.Count()); Assert.Equal(2, r.Count(x => (bool)x["Completed"] == true)); } }