private static void SetCreatedColumn(PropertyModel column)
 {
     if (column.Name == "CreateDate" || column.Name == "ModifyDate")
     {
         column.DefaultValueSql = "GETDATE()";
     }
 }
 private static void SetDefaultValueSql(PropertyModel column)
 {
     switch (column.Name)
     {
         case "Position":
             {
                 column.DefaultValueSql = "0";
                 break;
             }
         case "Available":
             {
                 column.DefaultValueSql = "1";
                 break;
             }
         case "Secret":
             {
                 column.DefaultValueSql = "NEWID()";
                 break;
             }
         case "Created":
         case "Updated":
         case "Publish":
             {
                 column.DefaultValueSql = "GETDATE()";
                 break;
             }
     }
 }
 private static void SetCreatedUtcColumn(PropertyModel column)
 {
     if (column.Name == "CreatedUtc")
     {
         column.DefaultValueSql = "GETUTCDATE()";
     }
 }
 private static void SetDateCreatedColumn(PropertyModel column)
 {
     if (column.Name == "DateCreated" || column.Name == "TimeSend")
     {
         column.DefaultValueSql = "GETDATE()";
     }
 }
 /// <summary>
 /// Builds the store type usage for the specified <paramref name="storeTypeName"/> using the facets from the specified <paramref name="propertyModel"/>.
 /// </summary>
 /// <param name="storeTypeName">Name of the store type.</param>
 /// <param name="propertyModel">The target property.</param>
 /// <returns>A store-specific TypeUsage</returns>
 protected virtual TypeUsage BuildStoreTypeUsage(string storeTypeName, PropertyModel propertyModel)
 {
     var storeType = ProviderManifest.GetStoreTypes()
                            .SingleOrDefault(p => string.Equals(p.Name, storeTypeName, StringComparison.OrdinalIgnoreCase));
     
     return storeType == null
         ? null
         : TypeUsage.Create(storeType, propertyModel.ToFacetValues());
 }
 string BuildPropertyType(PropertyModel propertyModel)
 {
     var storeTypeName = propertyModel.StoreType;
     var typeUsage = ProviderManifest.GetStoreType(propertyModel.TypeUsage);
     if (!string.IsNullOrWhiteSpace(storeTypeName))
     {
         typeUsage = BuildStoreTypeUsage(storeTypeName, propertyModel) ?? typeUsage;
     }
     return SqlGenerator.GetSqlPrimitiveType(typeUsage);
 }
        private string BuildPropertyType(PropertyModel propertyModel)
        {
            DebugCheck.NotNull(propertyModel);

            var originalStoreTypeName = propertyModel.StoreType;
            var typeUsage = ProviderManifest.GetStoreType(propertyModel.TypeUsage);

            if (string.IsNullOrWhiteSpace(originalStoreTypeName))
            {
                originalStoreTypeName = typeUsage.EdmType.Name;
            }
            else
            {
                var storeTypeUsage = BuildStoreTypeUsage(originalStoreTypeName, propertyModel);

                typeUsage = storeTypeUsage ?? typeUsage;
            }

            var storeTypeName = originalStoreTypeName;

            const string MaxSuffix = "(max)";

            if (storeTypeName.EndsWith(MaxSuffix, StringComparison.Ordinal))
            {
                storeTypeName = Quote(storeTypeName.Substring(0, storeTypeName.Length - MaxSuffix.Length)) + MaxSuffix;
            }
            else
            {
                storeTypeName = Quote(storeTypeName);
            }

            switch (originalStoreTypeName)
            {
                case "decimal":
                case "numeric":
                    storeTypeName += "(" + (propertyModel.Precision ?? typeUsage.GetPrecision())
                                     + ", " + (propertyModel.Scale ?? typeUsage.GetScale()) + ")";
                    break;
                case "datetime2":
                case "datetimeoffset":
                case "time":
                    storeTypeName += "(" + (propertyModel.Precision ?? typeUsage.GetPrecision()) + ")";
                    break;
                case "binary":
                case "varbinary":
                case "nvarchar":
                case "varchar":
                case "char":
                case "nchar":
                    storeTypeName += "(" + (propertyModel.MaxLength ?? typeUsage.GetMaxLength()) + ")";
                    break;
            }

            return storeTypeName;
        }