CodeMemberField GetCollectionCache(CollectionBaseInfo coli) { CodeMemberField field = new CodeMemberField(GetCollectionPropertyType(coli.GetItemClass().Name), "_collectionCache_" + coli.Name); field.Attributes = MemberAttributes.Private; field.InitExpression = new CodePrimitiveExpression(null); return field; }
static CodeMemberProperty GetCollectionLinqQuery(CollectionBaseInfo coli, CodeExpression whereExpression) { string elementType = coli.GetItemClass().Name; CodeMemberProperty prop = new CodeMemberProperty(); prop.Name = coli.Name + "Query"; prop.Attributes = MemberAttributes.Final | MemberAttributes.Public; prop.Type = new CodeTypeReference(new CodeTypeReference(typeof(System.Linq.IQueryable<>)).BaseType, new CodeTypeReference(elementType)); prop.GetStatements.Add( new CodeMethodReturnStatement( new CodeObjectCreateExpression( new CodeTypeReference(new CodeTypeReference(typeof(Sooda.Linq.SoodaQuerySource<>)).BaseType, new CodeTypeReference(elementType)), new CodeMethodInvokeExpression(This, "GetTransaction"), new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(elementType + "_Factory"), "TheClassInfo"), whereExpression ))); return prop; }