public override string GetTableName(ModelDefinition modelDef) { return modelDef.IsInSchema ? ApplyNameRestrictions(modelDef.Schema) + "." + ApplyNameRestrictions(GetTableName(modelDef.ModelName)) : GetTableName(modelDef.ModelName); }
public override string GetTableNameDelimited(ModelDefinition modelDef) { if (!modelDef.IsInSchema) return base.GetTableNameDelimited(modelDef); return string.Format("\"{0}_{1}\"", modelDef.Schema, modelDef.ModelName); }
public override string ToSelectStatement(ModelDefinition modelDef, string selectExpression, string bodyExpression, string orderByExpression = null, int? offset = null, int? rows = null) { var sb = StringBuilderCache.Allocate() .Append(selectExpression) .Append(bodyExpression); if (orderByExpression != null) sb.Append(orderByExpression); if (offset != null || rows != null) { if (orderByExpression.IsEmpty()) { var orderBy = offset == null && rows == 1 //Avoid for Single requests ? "1" : this.GetQuotedColumnName(modelDef, modelDef.PrimaryKey); sb.Append(" ORDER BY " + orderBy); } sb.Append(" OFFSET ").Append(offset.GetValueOrDefault()).Append(" ROWS"); if (rows != null) sb.Append(" FETCH NEXT ").Append(rows.Value).Append(" ROWS ONLY"); } return StringBuilderCache.ReturnAndFree(sb); }
public static string GetQuotedColumnName(this IOrmLiteDialectProvider dialect, ModelDefinition modelDef, FieldDefinition fieldDef) { return dialect.GetQuotedTableName(modelDef.ModelName) + "." + dialect.GetQuotedColumnName(fieldDef.FieldName); }
public override string ToSelectStatement(ModelDefinition modelDef, string selectExpression, string bodyExpression, string orderByExpression = null, int? offset = null, int? rows = null) { var sb = new StringBuilder(selectExpression) .Append(bodyExpression); if (orderByExpression != null) sb.Append(orderByExpression); if (offset != null || rows != null) { if (orderByExpression.IsEmpty()) sb.Append(" ORDER BY 1"); sb.Append(" OFFSET ").Append(offset.GetValueOrDefault()).Append(" ROWS"); if (rows != null) sb.Append(" FETCH NEXT ").Append(rows.Value).Append(" ROWS ONLY"); } return sb.ToString(); }
public static string GetQuotedColumnName(this IOrmLiteDialectProvider dialect, ModelDefinition tableDef, string fieldName) { return dialect.GetQuotedTableName(tableDef) + "." + dialect.GetQuotedColumnName(fieldName); }
public ContentModel(Engine engine, ModelVariantIdentifier variant, ModelDefinition definition, ModelQuality quality) : base(engine) { this.Definition = definition; this.Quality = quality; this.Variant = variant; this.Transformation = Matrix.Identity; Init(); }
public AnimatedModel(Engine engine, Skeleton skeleton, ModelVariantIdentifier variant, ModelDefinition definition, ModelQuality quality) : base(engine, variant, definition, quality) { Skeleton = skeleton; _AnimationPlayer = new AnimationPlayer(); var nameMap = new Dictionary<string, int>(); for (var i = 0; i < Skeleton.BoneNames.Length; ++i) nameMap.Add(Skeleton.BoneNames[i], i); _BoneMap = Definition.BoneNames.Select(n => nameMap[n]).ToArray(); _InvertedReferencePose = Skeleton.ReferencePose.Select(_ => Matrix.Invert(_)).ToArray(); }
public Content.PrimitiveModel Get(ModelDefinition definition, ModelQuality quality) { var key = Tuple.Create(definition.File.Path, quality); Content.PrimitiveModel primitive; if (_Primitives.TryGetValue(key, out primitive)) return primitive; var mdl = definition.GetModel(quality); primitive = new Content.PrimitiveModel(_Engine.Device, mdl); _Primitives.Add(key, primitive); return primitive; }
private IModelDefinition CreateModel(Type type) { var model = new ModelDefinition(); if(type.BaseType != typeof(ModelBase)) { var baseModel = GetModelFor(type.BaseType); foreach(var propertyDefinition in baseModel) { model.AddProperty(propertyDefinition); } } return model; }
public string GenCreateTableSql(ModelDefinition md) { var ret = new StringBuilder(); ret.Append("CREATE TABLE " + md.TableName + " ("); var i = 1; foreach (var cfd in md.PropertyColumnDic.Values) { ret.Append(GenColumnCreateTableSql(cfd)); if (i != md.PropertyColumnDic.Values.Count) { ret.Append(" ,"); } i++; } ret.Append(")"); return ret.ToString(); }
public override string GetTableName(ModelDefinition modelDef) { return(GetTableName(modelDef.ModelName, modelDef.Schema)); }
protected virtual void CreateHierarchyJoin(ModelDefinition actualHierarchyTableDef, ModelDefinition mainHierarchyTableDef) { }
public virtual string GenDropTableSql(ModelDefinition md) { var ret = new StringBuilder(); ret.Append(" DROP TABLE "); ret.Append(md.TableName); return ret.ToString(); }
public string GenUpdateSql(ModelDefinition md,Object obj) { var ret = new StringBuilder(); var fields = new StringBuilder(); var valueFields = new StringBuilder(); fields.Append(GenInsertColFields(md)); valueFields.Append(GenInsertValueFields(md)); ret.Append(" UPDATE "); ret.Append(md.TableName +" SET "); var objMdf = new ModelDefinitionConverter().ConverClassToModelDefinition(obj.GetType()); int i = 1; foreach (var df in objMdf.PropertyColumnDic.Values) { ret.Append(" " + df.ColumnName + "=@" + df.PropName + " "); if (i < objMdf.PropertyColumnDic.Values.Count) { ret.Append(" , "); i++; } } return ret.ToString(); }
protected virtual bool ShouldReturnOnInsert(ModelDefinition modelDef, FieldDefinition fieldDef) => fieldDef.ReturnOnInsert || (fieldDef.IsPrimaryKey && fieldDef.AutoIncrement && HasInsertReturnValues(modelDef)) || fieldDef.AutoId;
public virtual string GenInsertSql(ModelDefinition md) { var ret = new StringBuilder(); var fields = new StringBuilder(); var valueFields = new StringBuilder(); fields.Append(GenInsertColFields(md)); valueFields.Append(GenInsertValueFields(md)); ret.Append(" INSERT INTO "); ret.Append(md.TableName+"( "); ret.Append(fields); ret.Append(" ) VALUES ( "); ret.Append(valueFields); ret.Append(") "); return ret.ToString(); }
public ContentModel(Engine engine, ModelVariantIdentifier variant, ModelDefinition definition) : this(engine, variant, definition, ModelQuality.High) { }
protected override string ToCreateIndexStatement(bool isUnique, string indexName, ModelDefinition modelDef, string fieldName, bool isCombined = false, FieldDefinition fieldDef = null) { return(string.Format("CREATE {0} INDEX {1} ON {2} ({3} ); \n", isUnique ? "UNIQUE" : "", indexName, GetQuotedTableName(modelDef), GetQuotedColumnName(fieldName))); }
protected string GetRefSelfSql(ModelDefinition modelDef, FieldDefinition refSelf, ModelDefinition refModelDef) { //Load Self Table.RefTableId PK q.Select(dialectProvider.GetQuotedColumnName(modelDef, refSelf)); var subSqlRef = q.ToSelectStatement(); var sqlRef = $"SELECT {dialectProvider.GetColumnNames(refModelDef)} " + $"FROM {dialectProvider.GetQuotedTableName(refModelDef)} " + $"WHERE {dialectProvider.GetQuotedColumnName(refModelDef.PrimaryKey)} " + $"IN ({subSqlRef})"; return(sqlRef); }
public override string ToSelectStatement(ModelDefinition modelDef, string selectExpression, string bodyExpression, string orderByExpression = null, int?offset = null, int?rows = null) { var sb = StringBuilderCache.Allocate() .Append(selectExpression) .Append(bodyExpression); if (!offset.HasValue && !rows.HasValue) { return(StringBuilderCache.ReturnAndFree(sb) + orderByExpression); } if (offset.HasValue && offset.Value < 0) { throw new ArgumentException(string.Format("Skip value:'{0}' must be>=0", offset.Value)); } if (rows.HasValue && rows.Value < 0) { throw new ArgumentException(string.Format("Rows value:'{0}' must be>=0", rows.Value)); } var skip = offset.HasValue ? offset.Value : 0; var take = rows.HasValue ? rows.Value : int.MaxValue; var selectType = selectExpression.StartsWithIgnoreCase("SELECT DISTINCT") ? "SELECT DISTINCT" : "SELECT"; //Temporary hack till we come up with a more robust paging sln for SqlServer if (skip == 0) { var sql = StringBuilderCache.ReturnAndFree(sb) + orderByExpression; if (take == int.MaxValue) { return(sql); } if (sql.Length < "SELECT".Length) { return(sql); } sql = selectType + " TOP " + take + sql.Substring(selectType.Length); return(sql); } // Required because ordering is done by Windowing function if (string.IsNullOrEmpty(orderByExpression)) { if (modelDef.PrimaryKey == null) { throw new ApplicationException("Malformed model, no PrimaryKey defined"); } orderByExpression = string.Format("ORDER BY {0}", this.GetQuotedColumnName(modelDef, modelDef.PrimaryKey)); } var ret = string.Format( "SELECT * FROM (SELECT {0}, ROW_NUMBER() OVER ({1}) As RowNum {2}) AS RowConstrainedResult WHERE RowNum > {3} AND RowNum <= {4}", selectExpression.Substring(selectType.Length), orderByExpression, bodyExpression, skip, take == int.MaxValue ? take : skip + take); return(ret); }
private string GetTriggerName(ModelDefinition modelDef) { return(RowVersionTriggerFormat.Fmt(GetTableName(modelDef))); }
public AnimatedModel(Engine engine, Skeleton skeleton, ModelVariantIdentifier variant, ModelDefinition definition, ModelQuality quality) : base(engine, variant, definition, quality) { Skeleton = skeleton; _AnimationPlayer = new AnimationPlayer(); var nameMap = new Dictionary <string, int>(); for (var i = 0; i < Skeleton.BoneNames.Length; ++i) { nameMap.Add(Skeleton.BoneNames[i], i); } _BoneMap = Definition.BoneNames.Select(n => nameMap[n]).ToArray(); _InvertedReferencePose = Skeleton.ReferencePose.Select(_ => Matrix.Invert(_)).ToArray(); }
public AnimatedModel(Engine engine, Skeleton skeleton, ModelVariantIdentifier variant, ModelDefinition definition) : this(engine, skeleton, variant, definition, ModelQuality.High) { }
public bool MoveNext() { if (MoveNextStain()) return true; while (_EquipmentIterator.MoveNext()) { var eq = _EquipmentIterator.Current; var charType = RaceCharacterTypes[eq.RacesEquippableBy.First().Key]; if (!eq.EquippableByMale) charType += 100; _CurrentModel = eq.GetModel(charType, out _CurrentVariant); if (_CurrentModel == null) continue; RenderFromOppositeSide = eq.ItemUICategory.Key == 1 || eq.ItemUICategory.Key == 10; // PGL/MNK and books CurrentBoundingBox = _CurrentModel.BoundingBoxes.Value2.Scale(1.35f); // Not sure what the first one is for, but some are very strange. if (_StainEnumerator == null) _IsCurrentStained = false; else _IsCurrentStained = eq.IsDyeable; if (_IsCurrentStained) { _StainEnumerator.Reset(); MoveNextStain(); } else { CurrentComponent = new Content.ContentModel(_Engine, _CurrentVariant, _CurrentModel); CurrentTargetFile = GetTargetFile(_EquipmentIterator.Current); CurrentName = GetName(_EquipmentIterator.Current); } return true; } return false; }
public virtual string GetSchemaName(ModelDefinition modelDef) { return GetSchemaName(modelDef.Schema); }
/// <summary>A Type extension method that gets model definition.</summary> /// <param name="modelType">The modelType to act on.</param> /// <returns>The model definition.</returns> public static ModelDefinition GetModelDefinition(this Type modelType) { ModelDefinition modelDef; if (typeModelDefinitionMap.TryGetValue(modelType, out modelDef)) return modelDef; if (modelType.IsValueType() || modelType == typeof(string)) return null; var modelAliasAttr = modelType.FirstAttribute<AliasAttribute>(); var schemaAttr = modelType.FirstAttribute<SchemaAttribute>(); modelDef = new ModelDefinition { ModelType = modelType, Name = modelType.Name, Alias = modelAliasAttr != null ? modelAliasAttr.Name : null, Schema = schemaAttr != null ? schemaAttr.Name : null }; modelDef.CompositeIndexes.AddRange( modelType.GetCustomAttributes(typeof(CompositeIndexAttribute), true).ToList() .ConvertAll(x => (CompositeIndexAttribute)x)); var objProperties = modelType.GetProperties( BindingFlags.Public | BindingFlags.Instance).ToList(); var hasIdField = CheckForIdField(objProperties); var i = 0; foreach (var propertyInfo in objProperties) { var sequenceAttr = propertyInfo.FirstAttribute<SequenceAttribute>(); var computeAttr= propertyInfo.FirstAttribute<ComputeAttribute>(); var pkAttribute = propertyInfo.FirstAttribute<PrimaryKeyAttribute>(); var decimalAttribute = propertyInfo.FirstAttribute<DecimalLengthAttribute>(); var belongToAttribute = propertyInfo.FirstAttribute<BelongToAttribute>(); var isFirst = i++ == 0; var isPrimaryKey = propertyInfo.Name == OrmLiteConfig.IdField || (!hasIdField && isFirst) || pkAttribute != null; var isNullableType = IsNullableType(propertyInfo.PropertyType); var isNullable = (!propertyInfo.PropertyType.IsValueType && propertyInfo.FirstAttribute<RequiredAttribute>() == null) || isNullableType; var propertyType = isNullableType ? Nullable.GetUnderlyingType(propertyInfo.PropertyType) : propertyInfo.PropertyType; var aliasAttr = propertyInfo.FirstAttribute<AliasAttribute>(); var indexAttr = propertyInfo.FirstAttribute<IndexAttribute>(); var isIndex = indexAttr != null; var isUnique = isIndex && indexAttr.Unique; var stringLengthAttr = propertyInfo.FirstAttribute<StringLengthAttribute>(); var defaultValueAttr = propertyInfo.FirstAttribute<DefaultAttribute>(); var referencesAttr = propertyInfo.FirstAttribute<ReferencesAttribute>(); var foreignKeyAttr = propertyInfo.FirstAttribute<ForeignKeyAttribute>(); if (decimalAttribute != null && stringLengthAttr == null) stringLengthAttr = new StringLengthAttribute(decimalAttribute.Precision); var fieldDefinition = new FieldDefinition { Name = propertyInfo.Name, Alias = aliasAttr != null ? aliasAttr.Name : null, FieldType = propertyType, PropertyInfo = propertyInfo, IsNullable = isNullable, IsPrimaryKey = isPrimaryKey, AutoIncrement = isPrimaryKey && propertyInfo.FirstAttribute<AutoIncrementAttribute>() != null, IsIndexed = isIndex, IsUnique = isUnique, FieldLength = stringLengthAttr != null ? stringLengthAttr.MaximumLength : (int?)null, DefaultValue = defaultValueAttr != null ? defaultValueAttr.DefaultValue : null, ForeignKey = foreignKeyAttr == null ? referencesAttr == null ? null : new ForeignKeyConstraint(referencesAttr.Type) : new ForeignKeyConstraint(foreignKeyAttr.Type, foreignKeyAttr.OnDelete, foreignKeyAttr.OnUpdate, foreignKeyAttr.ForeignKeyName), GetValueFn = propertyInfo.GetPropertyGetterFn(), SetValueFn = propertyInfo.GetPropertySetterFn(), Sequence = sequenceAttr != null ? sequenceAttr.Name : string.Empty, IsComputed = computeAttr != null, ComputeExpression = computeAttr != null ? computeAttr.Expression : string.Empty, Scale = decimalAttribute != null ? decimalAttribute.Scale : (int?)null, BelongToModelName = belongToAttribute != null ? belongToAttribute.BelongToTableType.GetModelDefinition().ModelName : null, }; if (propertyInfo.FirstAttribute<IgnoreAttribute>() != null) modelDef.IgnoredFieldDefinitions.Add(fieldDefinition); else modelDef.FieldDefinitions.Add(fieldDefinition); } modelDef.SqlSelectAllFromTable = "SELECT {0} FROM {1} ".Fmt(OrmLiteConfig.DialectProvider.GetColumnNames(modelDef), OrmLiteConfig.DialectProvider.GetQuotedTableName( modelDef)); Dictionary<Type, ModelDefinition> snapshot, newCache; do { snapshot = typeModelDefinitionMap; newCache = new Dictionary<Type, ModelDefinition>(typeModelDefinitionMap); newCache[modelType] = modelDef; } while (!ReferenceEquals( Interlocked.CompareExchange(ref typeModelDefinitionMap, newCache, snapshot), snapshot)); return modelDef; }
/// <summary> /// Gets the name of the table. /// </summary> /// <param name="modelDef">The model definition.</param> /// <returns>Returns the name of the table.</returns> public string GetTableName(ModelDefinition modelDef) { return(this.GetTableName(modelDef.ModelName)); }
public static int Main(string[] args) { int retval = 0; SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "comp", 1); // create the document SBMLDocument document = new SBMLDocument(sbmlns); // create the Model Model model = document.createModel(); // create a replacement parameter Parameter parameter = model.createParameter(); parameter.setId("x"); parameter.setConstant(true); // create a parameter to be a conversion factor Parameter param2 = model.createParameter(); param2.setId("x_conv"); param2.setMetaId("_110013"); param2.setConstant(true); // create a parameter to be a conversion factor Parameter param3 = model.createParameter(); param3.setId("lcf"); param3.setConstant(true); // Convert parameter to the plugin version so we can add the new attributes and replacements to it. CompSBasePlugin splugin = (CompSBasePlugin) (parameter.getPlugin("comp")); // Add a replaced element. ReplacedElement rep1 = splugin.createReplacedElement(); int rv = rep1.setSubmodelRef("submod1"); rv = rep1.setConversionFactor("x_conv"); rv = rep1.setIdRef("param1"); // Add a second replaced element in a different way. ReplacedElement rep2 = new ReplacedElement(); rv = rep2.setSubmodelRef("submod2"); rv = rep2.setDeletion("del1"); rv = splugin.addReplacedElement(rep2); //Now create a replaced element that points into a submodel. rep2.unsetDeletion(); rep2.setIdRef("submod2"); SBaseRef sbr5 = rep2.createSBaseRef(); sbr5.setIdRef("submodelG"); SBaseRef sbr6 = sbr5.createSBaseRef(); sbr6.setIdRef("buriedElement"); splugin.addReplacedElement(rep2); // Create a submodel CompModelPlugin mplugin = (CompModelPlugin) (model.getPlugin("comp")); CompSBMLDocumentPlugin compdoc = (CompSBMLDocumentPlugin) (document.getPlugin("comp")); compdoc.setRequired(true); ModelDefinition moddef1 = compdoc.createModelDefinition(); moddef1.setId("Mod1"); Parameter m1param1 = moddef1.createParameter(); m1param1.setId("param1"); m1param1.setConstant(true); Parameter m1param2 = moddef1.createParameter(); m1param2.setId("param2"); m1param2.setConstant(false); m1param2.setValue(3.2); ModelDefinition moddef2 = new ModelDefinition(); moddef2.setId("Mod2"); Parameter subparam2 = moddef2.createParameter(); subparam2.setId("subparam2"); subparam2.setConstant(false); compdoc.addModelDefinition(moddef2); ExternalModelDefinition extmod1 = compdoc.createExternalModelDefinition(); extmod1.setId("ExtMod1"); extmod1.setSource("urn:miriam:biomodels.db:BIOMD0000000127"); ExternalModelDefinition extmod2 = new ExternalModelDefinition(); extmod2.setId("ExtMod2"); extmod2.setSource("otherfile.xml"); extmod2.setModelRef("modelnamethere"); extmod2.setMd5("406022s908ge74sklj"); compdoc.addExternalModelDefinition(extmod2); Submodel submod1 = mplugin.createSubmodel(); submod1.setId("submod1"); submod1.setModelRef("Mod1"); Deletion del1 = submod1.createDeletion(); del1.setId("deletionA"); del1.setIdRef("param2"); Submodel submod2 = new Submodel(); submod2.setId("submod2"); submod2.setModelRef("ExtMod1"); submod2.setSubstanceConversionFactor("subcf"); submod2.setTimeConversionFactor("tcf"); submod2.setExtentConversionFactor("xtf"); Deletion del2 = new Deletion(); del2.setId("deletionB"); del2.setMetaIdRef("_0010110"); rv = submod2.addDeletion(del2); del2.setId("deletionC"); del2.unsetMetaIdRef(); del2.setPortRef("port2"); rv = submod2.addDeletion(del2); del2.unsetId(); del2.unsetPortRef(); del2.setUnitRef("mph"); rv = submod2.addDeletion(del2); del2.unsetUnitRef(); del2.setIdRef("submodG"); SBaseRef sbr = del2.createSBaseRef(); sbr.setIdRef("element5"); rv = submod2.addDeletion(del2); Deletion del3 = new Deletion(); del3.setIdRef("submodG"); SBaseRef sbr2 = new SBaseRef(); sbr2.setIdRef("subsubmodQ"); SBaseRef subsbr = sbr2.createSBaseRef(); subsbr.setPortRef("toBdel"); del3.setSBaseRef(sbr2); submod2.addDeletion(del3); mplugin.addSubmodel(submod2); Port port1 = mplugin.createPort(); port1.setId("port1"); port1.setMetaIdRef("_110013"); Port port2 = new Port(); port2.setId("port2"); port2.setIdRef("x"); mplugin.addPort(port2); port2.setId("port3"); port2.setIdRef("submod2"); port2.setSBaseRef(sbr2); mplugin.addPort(port2); libsbml.writeSBMLToFile(document, "comp_example1.xml"); document = libsbml.readSBMLFromFile("comp_example1.xml"); if (document == null) { Console.WriteLine("Error reading back in file."); retval = -1; } else { document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false); document.checkConsistency(); if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 || document.getErrorLog().getNumFailsWithSeverity(3) > 0) { OStringStream stream = new OStringStream(); document.printErrors(stream); Console.WriteLine("Errors encoutered when round-tripping SBML file: \n" + stream.str()); retval = -1; } libsbml.writeSBMLToFile(document, "comp_example1_rt.xml"); } return retval; }
private string GetGenericRepresentation(Type type, Func <Type, string> getTypedParameterRepresentation, ModelDefinition model = null) { string res; res = type.Name; int index = res.IndexOf('`'); if (index > -1) { res = res.Substring(0, index); } Type[] args = type.GetGenericArguments(); res += "<"; for (int i = 0; i < args.Length; i++) { if (i > 0) { res += ", "; } //Recursivly find nested arguments var arg = args[i]; if (model != null && model.IsGenericArgument(arg.Name)) { res += model.GetGenericArgument(arg.Name); } else { res += getTypedParameterRepresentation(arg); } } res += ">"; return(res); }
public virtual string GenSelectSql(ModelDefinition md) { var ret = new StringBuilder(); ret.Append(" SELECT "); int i = 1; foreach (var cdf in md.PropertyColumnDic.Values) { ret.Append(cdf.ColumnName + " " + cdf.PropName); if (i < md.PropertyColumnDic.Count) { ret.Append(" , "); i++; } } ret.Append(" FROM "+ md.TableName + " "); return ret.ToString(); }
/// <summary> /// Gets the name of the schema. /// </summary> /// <param name="modelDef">The model definition.</param> /// <returns>Returns the name of the schema</returns> public string GetSchemaName(ModelDefinition modelDef) { return(this.GetSchemaName(modelDef.Schema)); }
private string GenInsertValueFields(ModelDefinition md) { var ret = ""; var i = 1; foreach (var mdf in md.PropertyColumnDic.Values) { ret += " @" + mdf.PropName; if (i < md.PropertyColumnDic.Values.Count) { ret+=" ,"; } i++; } return ret; }
public virtual string GenDeleteSql(ModelDefinition md) { var ret = new StringBuilder(); ret.Append(" DELETE "); ret.Append(" FROM "+ md.TableName + " "); return ret.ToString(); }
public override bool HasInsertReturnValues(ModelDefinition modelDef) => modelDef.FieldDefinitions.Any(x => x.ReturnOnInsert || (x.AutoId && x.FieldType == typeof(Guid)));
public virtual string GetTableName(ModelDefinition modelDef) { return(GetTableName(modelDef.ModelName, modelDef.Schema)); }
public override string GetTableName(ModelDefinition modelDef) { return GetTableName(modelDef.ModelName); }
public string GetForeignKeyName(ModelDefinition modelDef, ModelDefinition refModelDef, INamingStrategy NamingStrategy, FieldDefinition fieldDef) { if (ForeignKeyName.IsNullOrEmpty()) { var modelName = modelDef.IsInSchema ? modelDef.Schema + "_" + NamingStrategy.GetTableName(modelDef.ModelName) : NamingStrategy.GetTableName(modelDef.ModelName); var refModelName = refModelDef.IsInSchema ? refModelDef.Schema + "_" + NamingStrategy.GetTableName(refModelDef.ModelName) : NamingStrategy.GetTableName(refModelDef.ModelName); return string.Format("FK_{0}_{1}_{2}", modelName, refModelName, fieldDef.FieldName); } else { return ForeignKeyName; } }
protected override string ToCreateIndexStatement(bool isUnique, string indexName, ModelDefinition modelDef, string fieldName, bool isCombined = false, FieldDefinition fieldDef = null) { var fieldNames = fieldName.Split(',') .Map(x => NamingStrategy.GetColumnName(x.LeftPart(' '))); return($"CREATE {(isUnique ? "UNIQUE" : "")} INDEX {indexName} ON {GetQuotedTableName(modelDef)} ({string.Join(",", fieldNames.ToArray())}); \n"); }
public virtual string GetTableName(ModelDefinition modelDef) { return GetTableName(modelDef.ModelName); }
protected string GetRefSelfSql(ModelDefinition modelDef, FieldDefinition refSelf, ModelDefinition refModelDef) { //Load Self Table.RefTableId PK var refQ = q.Clone(); refQ.Select(dialectProvider.GetQuotedColumnName(modelDef, refSelf)); refQ.OrderBy().ClearLimits(); //clear any ORDER BY or LIMIT's in Sub Select's var subSqlRef = refQ.ToMergedParamsSelectStatement(); var sqlRef = $"SELECT {dialectProvider.GetColumnNames(refModelDef)} " + $"FROM {dialectProvider.GetQuotedTableName(refModelDef)} " + $"WHERE {dialectProvider.GetQuotedColumnName(refModelDef.PrimaryKey)} " + $"IN ({subSqlRef})"; if (OrmLiteConfig.LoadReferenceSelectFilter != null) { sqlRef = OrmLiteConfig.LoadReferenceSelectFilter(refModelDef.ModelType, sqlRef); } return(sqlRef); }