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);
             }
         }
     }
 }
 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)
                              ));
         }
     }
 }
        private ModelFieldBindingSource <PropertyField> ResolveSourceField(
            SqlEntityModel <TEntity> sourceModel,
            FieldGraphPath <PropertyField> graphPath
            )
        {
            return(Search(sourceModel.Fields, new string[0]));

            ModelFieldBindingSource <PropertyField> Search(
                IEnumerable <SqlEntityField <TEntity> > fields,
                string[] parentPath
                )
            {
                foreach (var field in fields)
                {
                    var fieldPath = parentPath.Concat(new[] { field.FieldName }).ToArray();

                    if (field.TypeModelGraphPath.Equals(graphPath))
                    {
                        return(new ModelFieldBindingSource <PropertyField>(
                                   fieldPath, field
                                   ));
                    }

                    if (field.FieldModel != null && field.FieldModel.Fields.Count > 0)
                    {
                        var subSearchResult = Search(field.FieldModel.Fields, fieldPath);
                        if (subSearchResult != null)
                        {
                            return(subSearchResult);
                        }
                    }
                }

                return(null);
            }
        }
 public SqlOutBindingBuilder(SqlStorageModel <TEntity> sourceModel, SqlEntityModel <TEntity> targetModel) :
     base(sourceModel, targetModel)
 {
 }