Esempio n. 1
0
        public static API CreateObjectCreateAPI(TableMapping tableMapping)
        {
            API api = new API(API.APIType.Create, "Create" + tableMapping.ClassName, Parameter <API> .CreateDataObjectReturnParameter(tableMapping, Parameter <API> .ParameterQuantifier.Single, null, null), null, new List <Annotation <API> > {
                new Annotation <API>("summary", "Creates a new " + tableMapping.ClassName + " using the passed-in parameter value(s).", null)
            }, null);

            api.JoinToTableMapping(tableMapping);

            foreach (ColumnMapping cm in (from cm in tableMapping.NonPrimaryKeyColumnMappings
                                          where !cm.IsEncryptionColumn
                                          select cm))
            {
                Parameter <API>   parameter         = null;
                ForeignKeyMapping foreignKeyMapping = tableMapping.ContainingProject.ForeignKeyMappings.Where(fkm => fkm.ReferencedColumnMapping == cm).SingleOrDefault();

                if (cm.IsEnumeration)
                {
                    parameter = Parameter <API> .CreateEnumParameter(cm.FieldName, Parameter <API> .ParameterModifier.None, cm, cm.Nullable, null, null);
                }
                else if (cm.IsEncrypted)
                {
                    parameter = Parameter <API> .CreateOtherParameter(cm.DecryptionPropertyName, Parameter <API> .ParameterModifier.None, Parameter <API> .ParameterQuantifier.Single, "string", false, null, null);
                }
                else if (foreignKeyMapping != null)
                {
                    parameter = Parameter <API> .CreateOtherParameter(foreignKeyMapping.FieldName, Parameter <API> .ParameterModifier.None, Parameter <API> .ParameterQuantifier.Single, cm.TableMapping.ClassName, false, null, null);
                }
                else
                {
                    parameter = Parameter <API> .CreateOtherParameter(cm.FieldName, Parameter <API> .ParameterModifier.None, Parameter <API> .ParameterQuantifier.Single, cm.DataType, cm.Nullable, null, null);
                }

                api.Parameters.Add(parameter);
                parameter.JoinToParent(api);
            }

            return(api);
        }
Esempio n. 2
0
 public static Parameter <T> CreateDataObjectParameter(string name, Parameter <T> .ParameterModifier modifier, ParameterQuantifier quantifier, TableMapping dataTypeReferencedTableMapping, List <Annotation <Parameter <T> > > annotations, List <Attribute <Parameter <T> > > attributes)
 {
     return(new Parameter <T>(name, false, modifier, quantifier, Parameter <T> .ParameterType.DataObject, dataTypeReferencedTableMapping.ConnectionName, dataTypeReferencedTableMapping.SchemaName, dataTypeReferencedTableMapping.TableName, null, null, false, annotations, attributes));
 }
Esempio n. 3
0
 public void TransferTo(TableMapping tableMapping)
 {
     _tableMapping.APIs.Remove(this);
     _tableMapping = tableMapping;
     _tableMapping.APIs.Add(this);
 }