Пример #1
0
        public string WriteFilter(EntityQuery query)
        {
            StringWriter w = new StringWriter();

            foreach (var para in query.Parameters)
            {
                var isrequire    = para.ParameterType == EParameterType.Common;
                var datatype     = new DataTypeMetadata(para.Content, Data.Project, isrequire);
                var isPermission = (para.ParameterType == EParameterType.Permission).ToString().ToLower();
                if (datatype.IsCollection)
                {
                    w.WriteLine($"var {para.Name}=_builder.GetParameterArrayValue<{datatype.TypeName}>(\"para.Name\",{isPermission});");
                }
                else if (isrequire && datatype.BaseClrType.IsValueType)
                {
                    w.WriteLine($"var {para.Name}=_builder.GetParameterNullableValue<{datatype.TypeName}>(\"para.Name\",{isPermission});");
                }
                else
                {
                    w.WriteLine($"var {para.Name}=_builder.GetParameterValue<{datatype.TypeName}>(\"para.Name\",{isPermission});");
                }
            }
            foreach (var para in query.Parameters)
            {
                w.WriteLine($"_builder.Parameters.Add(\"{para.Name}\", {para.Name});");
            }

            int varindex = 1;

            this.WriteFilter(w, query.Filters, "_g0", ref varindex);

            return(w.GetStringBuilder().ToString());
        }
Пример #2
0
 public string GenerateReturnsEntityName(DataTypeMetadata data)
 {
     if (data.IsEntityType && data.EntityType.DataContext != null)
     {
         return("\"" + data.TypeName + "s\"");
     }
     return("");
 }
Пример #3
0
 private string GenerateReturnsPrefix(DataTypeMetadata data)
 {
     if (data.IsEntityType && data.EntityType.DataContext != null)
     {
         if (data.IsCollection)
         {
             return("CollectionFromEntitySet");
         }
         else
         {
             return("FromEntitySet");
         }
     }
     if (data.IsCollection)
     {
         return("Collection");
     }
     return("");
 }
Пример #4
0
 private string GenerateParameterPrefix(DataTypeMetadata data)
 {
     if (data.IsEntityType)
     {
         if (data.IsCollection)
         {
             return("CollectionEntity");
         }
         else
         {
             return("Entity");
         }
     }
     if (data.IsCollection)
     {
         return("Collection");
     }
     return("");
 }
Пример #5
0
 private string GenerateElementType(DataTypeMetadata data)
 {
     if (!data.IsEntityType && data.IsCollection)
     {
         var type = data.ClrType;
         if (type.IsArray)
         {
             return(type.GetElementType().FullName);
         }
         if (type.IsGenericType)
         {
             var types = type.GetGenericArguments();
             if (types.Length == 0)
             {
                 return(types[0].FullName);
             }
         }
     }
     return(data.TypeName);
 }
 public ProvideMetadataResult(DataTypeMetadata dataType, DataTypeMetadata lastVersionDataType)
 {
     DataType            = dataType;
     LastVersionDataType = lastVersionDataType;
 }