/// <summary> /// Main driver function. /// </summary> /// <param name="args"></param> public static void Generate(string outputFileName) { //The following functions are omitted because they have counterparts in the BCL string[] omittedFunctions = new[] { "Sum", "Min", "Max", "Average", "Avg", "Count", "BigCount", "Trim", "RTrim", "LTrim", "Concat", "Length", "Substring", "Replace", "IndexOf", "ToUpper", "ToLower", "Contains", "StartsWith", "EndsWith", "Year", "Month", "Day", "DayOfYear", "Hour", "Minute", "Second", "Millisecond", "CurrentDateTime", "CurrentDateTimeOffset", "CurrentUtcDateTime", "BitwiseAnd", "BitwiseOr", "BitwiseXor", "BitwiseNot", "Round", "Abs", "Power", "NewGuid", "Floor", "Ceiling", }; //The following functions are omitted from SqlFunctions because they already exist in EntityFunctions string[] omittedSqlFunctions = new[] { "STDEV", "STDEVP", "VAR", "VARP", "COUNT_BIG", "Left", "Right", "Reverse", "GetTotalOffsetMinutes", "TruncateTime", "CreateDateTime", "CreateDateTimeOffset", "CreateTime", "Add", "Diff", "Truncate", "SYSDATETIME", "SYSUTCDATETIME", "SYSDATETIMEOFFSET", "LEN", "LOWER", "UPPER", "NEWID", }; //Generate Sql Server function stubs String ssdl = @"<Schema Namespace='LinqFunctionStubsGenerator' Alias='Self' Provider='SampleEntityFrameworkProvider' ProviderManifestToken='2008' xmlns='http://schemas.microsoft.com/ado/2006/04/edm/ssdl'></Schema>"; XmlReader[] xmlReaders = new XmlReader[1]; xmlReaders[0] = XmlReader.Create(new StringReader(ssdl)); StoreItemCollection storeItemCollection = new StoreItemCollection(xmlReaders); IEnumerable <EdmFunction> sqlFunctions = storeItemCollection.GetItems <EdmFunction>() .Where(f => f.NamespaceName == "SqlServer") .Where(f => !(omittedFunctions.Concat(omittedSqlFunctions)).Contains(f.Name, StringComparer.OrdinalIgnoreCase)); FunctionStubFileWriter sqlStubsFileWriter = new FunctionStubFileWriter(sqlFunctions, GetFunctionNamingDictionary(), GetParameterNamingDictionary()); sqlStubsFileWriter.GenerateToFile(outputFileName, "SampleEntityFrameworkProvider", "SampleSqlFunctions", "SqlServer", true); }
/// <summary> /// Main driver function. /// </summary> /// <param name="args"></param> public static void Generate(string outputFileName) { //The following functions are omitted because they have counterparts in the BCL string[] omittedFunctions = new[] { "Sum", "Min", "Max", "Average", "Avg", "Count", "BigCount", "Trim", "RTrim", "LTrim", "Concat", "Length", "Substring", "Replace", "IndexOf", "ToUpper", "ToLower", "Contains", "StartsWith", "EndsWith", "Year", "Month", "Day", "DayOfYear", "Hour", "Minute", "Second", "Millisecond", "CurrentDateTime", "CurrentDateTimeOffset", "CurrentUtcDateTime", "BitwiseAnd", "BitwiseOr", "BitwiseXor", "BitwiseNot", "Round", "Abs", "Power", "NewGuid", "Floor", "Ceiling", }; //The following functions are omitted from SqlFunctions because they already exist in EntityFunctions string[] omittedSqlFunctions = new[] { "STDEV", "STDEVP", "VAR", "VARP", "COUNT_BIG", "Left", "Right", "Reverse", "GetTotalOffsetMinutes", "TruncateTime", "CreateDateTime", "CreateDateTimeOffset", "CreateTime", "Add", "Diff", "Truncate", "SYSDATETIME", "SYSUTCDATETIME", "SYSDATETIMEOFFSET", "LEN", "LOWER", "UPPER", "NEWID", }; //Generate Sql Server function stubs String ssdl = @"<Schema Namespace='LinqFunctionStubsGenerator' Alias='Self' Provider='SampleEntityFrameworkProvider' ProviderManifestToken='2008' xmlns='http://schemas.microsoft.com/ado/2006/04/edm/ssdl'></Schema>"; XmlReader[] xmlReaders = new XmlReader[1]; xmlReaders[0] = XmlReader.Create(new StringReader(ssdl)); StoreItemCollection storeItemCollection = new StoreItemCollection(xmlReaders); IEnumerable<EdmFunction> sqlFunctions = storeItemCollection.GetItems<EdmFunction>() .Where(f => f.NamespaceName == "SqlServer") .Where(f => !(omittedFunctions.Concat(omittedSqlFunctions)).Contains(f.Name, StringComparer.OrdinalIgnoreCase)); FunctionStubFileWriter sqlStubsFileWriter = new FunctionStubFileWriter(sqlFunctions, GetFunctionNamingDictionary(), GetParameterNamingDictionary()); sqlStubsFileWriter.GenerateToFile(outputFileName, "SampleEntityFrameworkProvider", "SampleSqlFunctions", "SqlServer", true); }