internal string FieldDefinition(DataFieldModel field) { if (field.IsCalculated) { return string.Format("[{0}] as ({1})", field.Name, field.Formula); } return string.Format("[{0}] {1}{2} {3} {4}", new object[] { field.Name, field.TypeString, field.IsIdentity ? string.Format(" identity({0}, {1})", field.IdentitySeed, field.IdentityIncr) : string.Empty, field.AllowNull ? "null" : "not null", (field.Default == string.Empty) ? string.Empty : ("default " + field.Default) }); }
internal void ScriptFieldProp(DataFieldModel field, string propName, string propValue, TextWriter sw) { sw.WriteLine(string.Format("exec sp_addextendedproperty @name='{0}',", SqlHelper.SqlString(propName))); sw.WriteLine(string.Format(" @value='{0}',", SqlHelper.SqlString(propValue))); sw.WriteLine(" @level0type='user', @level0name='dbo',"); sw.WriteLine(string.Format(" @level1type='table', @level1name='{0}',", field.Table.Name)); sw.WriteLine(string.Format(" @level2type='column', @level2name='{0}'", field.Name)); sw.WriteLine("GO"); sw.WriteLine(); }
internal string FieldDefinition(DataFieldModel field) { return string.Format("{0} {1} {2}", field.Name, Oracle8SpGenerator.MapTypesSqlToOracle(field.TypeString, true), field.AllowNull ? "NULL" : "NOT NULL"); }
internal void ScriptFieldComment(DataFieldModel field, string propValue, TextWriter sw) { if (propValue != string.Empty) { sw.WriteLine(string.Format("COMMENT ON COLUMN {0}.{1} IS", field.Table.Name, field.Name)); sw.WriteLine(string.Format(" '{0}';", SqlHelper.SqlString(propValue))); sw.WriteLine(); } }
public AssocModel Fields(DataFieldModel field1) { m_Fields.Clear(); m_Fields.Add(field1); return this; }
public AssocModel Fields(DataFieldModel field1, DataFieldModel field2, DataFieldModel field3, DataFieldModel field4) { m_Fields.Clear(); m_Fields.Add(field1); m_Fields.Add(field2); m_Fields.Add(field3); m_Fields.Add(field4); return this; }
public int Add(DataFieldModel dfModel) { foreach (DataFieldModel model in m_Items) { if (model.Name.ToLower().Equals(dfModel.Name.ToLower())) { throw new ArgumentException("There is already a DataFieldModel item in the container with the same name."); } } return m_Items.Add(dfModel); }
public void Remove(DataFieldModel dfModel) { m_Items.Remove(dfModel); }
private void AddAssoc(string assocName, string revAssocname, DataEntityModel table, bool mandatory, bool isInPK, params string[] fkFields) { AssocModel model = new AssocModel(assocName, table, this); model.ParentRole = assocName; model.ChildRole = (revAssocname == string.Empty) ? string.Format("ReverseOf{0}", assocName) : revAssocname; DataFieldContainer container = new DataFieldContainer(); foreach (DataFieldModel model2 in table.PKFields) { container.Add(model2); } int index = 0; foreach (DataFieldModel model3 in container) { string name = (index >= fkFields.Length) ? model3.Name : fkFields[index]; if (Fields[name] != null) { model.ForeignFields.Add(Fields[name]); } else { if (name == string.Empty) { name = model3.Name + "Parent"; if (Fields[name] != null) { name = name + Fields.Count; } } DataFieldModel df = new DataFieldModel(name, model3.TypeString).Descr(model3.Description); if (isInPK) { df.PKOrder = 0; } df.AllowNull = !mandatory; Add(df); model.ForeignFields.Add(df); } index++; } }
public void AddField(DataFieldModel field) { m_Fields.Add(field); }
public DataEntityModel Remove(DataFieldModel df) { m_Fields.Remove(df); TraceInfoEvent.Raise(string.Format("Field '{0}' removed from '{1}'.", df.Name, Name)); return this; }
public DataEntityModel AddPKField(DataFieldModel df) { df.PKOrder = m_PKFields.Add(df); TraceInfoEvent.Raise(string.Format("Field '{0}' added to the PK of '{1}'.", df.Name, Name)); return (df.Table = this); }
public DataEntityModel Add(DataFieldModel df) { m_Fields.Add(df); TraceInfoEvent.Raise(string.Format("Field '{0}' added to table '{1}'.", df.Name, Name)); df.Table = this; if ((df.DispOrder == 0) || (df.PKOrder == 0)) { AddDispField(df); } if (df.PKOrder == 0) { AddPKField(df); } if (df.CKOrder == 0) { AddCKField(df); } if (!df.IsCalculated && !df.IsIdentity) { m_InsertParamFields.Add(df); } if (!df.IsCalculated) { m_UpdateParamFields.Add(df); } if ((!df.IsPKField && !df.IsCalculated) && !df.IsIdentity) { m_UpdateSetFields.Add(df); } if (df.IsPKField && !df.IsIdentity) { m_ConstructorFields.Add(df); } return this; }
private void AddModificationField(DataFieldModel fi, CSharpTypeDef baseClass) { string normalizedName = fi.NormalizedName; CSharpFieldDef def = new CSharpFieldDef(); baseClass.Fields.Add(def); def.Attributes.Add("NonSerialized"); def.DefLine = string.Format("private bool m_{0}Modified = false;", fi.NormalizedName); def.CommentLine = string.Format("Is the '{0}' field modified?", fi.MappingName); CSharpPropertyDef def2 = new CSharpPropertyDef(); baseClass.Properties.Add(def2); def2.Comment.Summary = string.Format("Is the field '{0}' modified?", fi.MappingName); def2.HeaderLine = string.Format("public bool Is{0}Modified", normalizedName); def2.GetWriter.WriteLine(string.Format("return m_{0}Modified;", normalizedName)); CSharpFieldDef def3 = new CSharpFieldDef(); baseClass.Fields.Add(def3); def3.Attributes.Add("NonSerialized"); def3.DefLine = string.Format("private RuntimeException m_{0}Error = null;", fi.NormalizedName); def3.CommentLine = string.Format("Exception raised when modifying '{0}'", fi.MappingName); CSharpPropertyDef def4 = new CSharpPropertyDef(); baseClass.Properties.Add(def4); def4.Comment.Summary = string.Format("Is the field '{0}' valid?", fi.MappingName); def4.HeaderLine = string.Format("public bool Is{0}Valid", normalizedName); def4.GetWriter.WriteLine(string.Format("return m_{0}Error == null;", normalizedName)); CSharpPropertyDef def5 = new CSharpPropertyDef(); baseClass.Properties.Add(def5); def5.Comment.Summary = string.Format("Runtime exception field '{0}'", fi.MappingName); def5.HeaderLine = string.Format("public RuntimeException {0}Error", normalizedName); def5.GetWriter.WriteLine(string.Format("return m_{0}Error;", normalizedName)); }
private void AddInfoField(DataFieldModel fi, CSharpTypeDef baseClass) { string normalizedName = fi.NormalizedName; CSharpFieldDef def = new CSharpFieldDef(); baseClass.Fields.Add(def); def.Attributes.Add(string.Format("BindingField(\"{0}\")", fi.Name)); def.DefLine = string.Format("protected {0} m_{1} = new {0}();", SqlTypeMap.GetDBTypeFromFullName(fi.TypeString), normalizedName); def.CommentLine = string.Format("Member representing field '{0}'", fi.MappingName); CSharpPropertyDef def2 = new CSharpPropertyDef(); baseClass.Properties.Add(def2); def2.Comment.Summary = string.Format("Access information for field '{0}'", fi.MappingName); def2.HeaderLine = string.Format("public {0} {1}", SqlTypeMap.GetDBTypeFromFullName(fi.TypeString), normalizedName); def2.GetWriter.WriteLine(string.Format("return m_{0};", normalizedName)); if ((!fi.IsPKField && !fi.IsIdentity) && !fi.IsCalculated) { TextWriter setWriter = def2.SetWriter; setWriter.WriteLine("try"); setWriter.WriteLine("{"); setWriter.WriteLine(" m_{0} = value;", normalizedName); setWriter.WriteLine(" m_{0}Modified = true;", normalizedName); setWriter.WriteLine("}"); setWriter.WriteLine("catch (RuntimeException e)"); setWriter.WriteLine("{"); setWriter.WriteLine(" m_{0}Error = e;", normalizedName); setWriter.WriteLine("}"); setWriter.WriteLine("catch (Exception e)"); setWriter.WriteLine("{"); setWriter.WriteLine(" m_{0}Error = new InvalidPropertyValueException(\"Internal Exception\", e);", normalizedName); setWriter.WriteLine("}"); setWriter.WriteLine("SignModification();"); } }