public IEnumerable <BindingPair <SqlStorageField <TEntity>, PropertyField> > GetBindingPairs(
     SqlStorageModel <TEntity> sourceModel,
     SqlEntityModel <TEntity> targetModel)
 {
     foreach (var targetField in targetModel.Fields)
     {
         var sourceField = sourceModel.Fields.FirstOrDefault(
             q => q.TypeModelGraphPath.Path.SequenceEqual(targetField.TypeModelGraphPath.Path)
             );
         if (sourceField != null)
         {
             var bindingSource = new ModelFieldBindingSource <SqlStorageField <TEntity> >(
                 new[] { sourceField.FieldName },
                 sourceField
                 );
             yield return(new BindingPair <SqlStorageField <TEntity>, PropertyField>(
                              bindingSource,
                              new ModelFieldBindingTarget <PropertyField>(targetField.TypeModelGraphPath.Path, targetField)
                              ));
         }
         else if (targetField.FieldModel != null && targetField.FieldModel.Fields.Count > 0)
         {
             foreach (var pair in GetBindingPairs(sourceModel, targetField.FieldModel))
             {
                 yield return(pair);
             }
         }
     }
 }
Example #2
0
 protected override DataModelOutBinding <TEntity> BindingFactory(SqlStorageModel <TEntity> sourceModel, TypeModel targetModel, IReadOnlyList <ModelFieldBinding <SqlStorageField <TEntity>, PropertyField> > fieldBindings)
 {
     return(new DataModelOutBinding <TEntity>(
                sourceModel,
                targetModel as TypeModel <TEntity>,
                fieldBindings
                ));
 }
        public IEnumerable <BindingPair <PropertyField, SqlStorageField <TEntity> > > GetBindingPairs(
            TypeModel sourceModel,
            SqlStorageModel <TEntity> targetModel)
        {
            if (sourceModel is SqlEntityModel <TEntity> entityModel)
            {
                return(GetBindingPairs(entityModel, targetModel));
            }

            throw new InvalidOperationException("Can only bind entity models to storage models.");
        }
 public IEnumerable <BindingPair <PropertyField, SqlStorageField <TEntity> > > GetBindingPairs(
     SqlEntityModel <TEntity> sourceModel,
     SqlStorageModel <TEntity> targetModel)
 {
     foreach (var targetField in targetModel.Fields)
     {
         var sourceField = ResolveSourceField(sourceModel, targetField.TypeModelGraphPath);
         if (sourceField != null)
         {
             yield return(new BindingPair <PropertyField, SqlStorageField <TEntity> >(
                              sourceField,
                              new ModelFieldBindingTarget <SqlStorageField <TEntity> >(new[] { targetField.FieldName }, targetField)
                              ));
         }
     }
 }
Example #5
0
 public DataModelOutBinding(SqlStorageModel <TEntity> sourceModel, TypeModel <TEntity> targetModel, IReadOnlyList <ModelFieldBinding <SqlStorageField <TEntity>, PropertyField> > fieldBindings) :
     base(sourceModel, targetModel, fieldBindings)
 {
 }
Example #6
0
 protected SqlDataModel(SqlStorageModel storageModel)
 {
     StorageModel = storageModel;
 }
Example #7
0
 public SqlOutBindingBuilder(SqlStorageModel <TEntity> sourceModel, SqlEntityModel <TEntity> targetModel) :
     base(sourceModel, targetModel)
 {
 }
        public IEnumerable <BindingPair <SqlStorageField <TEntity>, PropertyField> > GetBindingPairs(SqlStorageModel <TEntity> sourceModel, TypeModel targetModel)
        {
            if (targetModel is SqlEntityModel <TEntity> entityModel)
            {
                return(GetBindingPairs(sourceModel, entityModel));
            }

            throw new InvalidOperationException("Can only bind storage models to entity models.");
        }
Example #9
0
 public DataModelInBinding(TypeModel <TEntity> sourceModel, SqlStorageModel <TEntity> targetModel, IReadOnlyList <ModelFieldBinding <PropertyField, SqlStorageField <TEntity> > > fieldBindings) :
     base(sourceModel, targetModel, fieldBindings)
 {
 }
Example #10
0
 protected override DataModelInBinding <TEntity> BindingFactory(TypeModel sourceModel, SqlStorageModel <TEntity> targetModel, IReadOnlyList <ModelFieldBinding <PropertyField, SqlStorageField <TEntity> > > fieldBindings)
 {
     return(new DataModelInBinding <TEntity>(
                sourceModel as TypeModel <TEntity>,
                targetModel,
                fieldBindings
                ));
 }