/// <summary> /// Add each query property. /// </summary> private void AddProperties() { if (_includeContextItems) { int propertyCount = 0; CodeMemberProperty endProperty = null; foreach (var table in _tables) { if (_data.TableList.Contains(table.TableName.ToUpper(), new ToUpperComparer()) == !_tableListExclusion) { // Create a new property member // and the accessor type. CodeMemberProperty valueProperty = new CodeMemberProperty(); valueProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final; // Add the region directive if at the beginning if (propertyCount == 0) { // Create a custom region. CodeRegionDirective startRegion = new CodeRegionDirective(CodeRegionMode.Start, "Public Ling Properties"); valueProperty.StartDirectives.Add(startRegion); // Increment the count. propertyCount++; } // Assign the name and get and set indictors. valueProperty.Name = LinqToDataTypes.Plural(table.TableName); valueProperty.HasGet = true; // Add the comments to the property. valueProperty.Comments.Add(new CodeCommentStatement("<summary>", true)); valueProperty.Comments.Add(new CodeCommentStatement("Gets, the " + table.TableName.ToLower() + " queryable provider property for the object.", true)); valueProperty.Comments.Add(new CodeCommentStatement("</summary>", true)); // Assign the property type for the property. // Get the data type of the property from // the sql data type. valueProperty.Type = new CodeTypeReference("Nequeo.Data.Linq.Query<" + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + table.TableName + ">"); // Add the code to the // get section of the property. valueProperty.GetStatements.Add(new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "GetTable<" + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + table.TableName + ">()"))); // Assign each property until the end. endProperty = valueProperty; // Add the property to the class. _targetClass.Members.Add(valueProperty); } } if (endProperty != null) { // Create a custom endregion. CodeRegionDirective endRegion = new CodeRegionDirective(CodeRegionMode.End, ""); endProperty.EndDirectives.Add(endRegion); } propertyCount = 0; endProperty = null; // if a views exist. if (GetDatabaseViews()) { foreach (var view in _views) { if (_data.TableList.Contains(view.TableName.ToUpper(), new ToUpperComparer()) == !_tableListExclusion) { // Create a new property member // and the accessor type. CodeMemberProperty valueProperty = new CodeMemberProperty(); valueProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final; // Add the region directive if at the beginning if (propertyCount == 0) { // Create a custom region. CodeRegionDirective startRegion = new CodeRegionDirective(CodeRegionMode.Start, "Public Ling Properties"); valueProperty.StartDirectives.Add(startRegion); // Increment the count. propertyCount++; } // Assign the name and get and set indictors. valueProperty.Name = LinqToDataTypes.Plural(view.TableName); valueProperty.HasGet = true; // Add the comments to the property. valueProperty.Comments.Add(new CodeCommentStatement("<summary>", true)); valueProperty.Comments.Add(new CodeCommentStatement("Gets, the " + view.TableName.ToLower() + " queryable provider property for the object.", true)); valueProperty.Comments.Add(new CodeCommentStatement("</summary>", true)); // Assign the property type for the property. // Get the data type of the property from // the sql data type. valueProperty.Type = new CodeTypeReference("Nequeo.Data.Linq.Query<" + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + view.TableName + ">"); // Add the code to the // get section of the property. valueProperty.GetStatements.Add(new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "GetTable<" + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + view.TableName + ">()"))); // Assign each property until the end. endProperty = valueProperty; // Add the property to the class. _targetClass.Members.Add(valueProperty); } } } if (endProperty != null) { // Create a custom endregion. CodeRegionDirective endRegion = new CodeRegionDirective(CodeRegionMode.End, ""); endProperty.EndDirectives.Add(endRegion); } } }
/// <summary> /// Add each query property. /// </summary> private void AddProperties() { foreach (var table in _tables) { if (_data.TableList.Contains(table.TableName.ToUpper()) == !_tableListExclusion) { // Create a new property member // and the accessor type. CodeMemberProperty valueProperty = new CodeMemberProperty(); valueProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final; // Assign the name and get and set indictors. valueProperty.Name = LinqToDataTypes.Plural(table.TableName); valueProperty.HasGet = true; // Add the comments to the property. valueProperty.Comments.Add(new CodeCommentStatement("<summary>", true)); valueProperty.Comments.Add(new CodeCommentStatement("Gets, the " + table.TableName.ToLower() + " queryable provider property for the object.", true)); valueProperty.Comments.Add(new CodeCommentStatement("</summary>", true)); // Assign the property type for the property. // Get the data type of the property from // the sql data type. valueProperty.Type = new CodeTypeReference("Nequeo.Data" + ".Linq.Data.QueryProvider.Query(Of " + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + table.TableName + ")"); // Add the code to the // get section of the property. valueProperty.GetStatements.Add(new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "GetTable(Of " + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + table.TableName + ")()"))); // Add the property to the class. _targetClass.Members.Add(valueProperty); } } // if a views exist. if (GetDatabaseViews()) { foreach (var view in _views) { if (_data.TableList.Contains(view.TableName.ToUpper()) == !_tableListExclusion) { // Create a new property member // and the accessor type. CodeMemberProperty valueProperty = new CodeMemberProperty(); valueProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final; // Assign the name and get and set indictors. valueProperty.Name = LinqToDataTypes.Plural(view.TableName); valueProperty.HasGet = true; // Add the comments to the property. valueProperty.Comments.Add(new CodeCommentStatement("<summary>", true)); valueProperty.Comments.Add(new CodeCommentStatement("Gets, the " + view.TableName.ToLower() + " queryable provider property for the object.", true)); valueProperty.Comments.Add(new CodeCommentStatement("</summary>", true)); // Assign the property type for the property. // Get the data type of the property from // the sql data type. valueProperty.Type = new CodeTypeReference("Nequeo.Data" + ".Linq.Data.QueryProvider.Query(Of " + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + view.TableName + ")"); // Add the code to the // get section of the property. valueProperty.GetStatements.Add(new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "GetTable(Of " + (!String.IsNullOrEmpty(_extendedName) ? "Data." + _extendedName + "." : "Data.") + view.TableName + ")()"))); // Add the property to the class. _targetClass.Members.Add(valueProperty); } } } }