comparison Demo/Linq/OverWCF/DataModel.generated.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 //---------------------------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by BLToolkit template for T4.
4 // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
5 // </auto-generated>
6 //---------------------------------------------------------------------------------------------------
7 using System;
8 using System.Collections.Generic;
9 using System.Linq;
10 using System.Linq.Expressions;
11 using System.Reflection;
12 using System.ServiceModel;
13 using System.Text;
14
15 using BLToolkit.Data;
16 using BLToolkit.Data.DataProvider;
17 using BLToolkit.Data.Linq;
18 using BLToolkit.Data.Sql;
19 using BLToolkit.Data.Sql.SqlProvider;
20 using BLToolkit.DataAccess;
21 using BLToolkit.Mapping;
22 using BLToolkit.ServiceModel;
23
24 namespace Linq.OverWCF
25 {
26 public partial class DataModel : ServiceModelDataContext
27 {
28 public Table<BinaryData> BinaryData { get { return this.GetTable<BinaryData>(); } }
29 public Table<Child> Child { get { return this.GetTable<Child>(); } }
30 public Table<DataTypes> DataTypes { get { return this.GetTable<DataTypes>(); } }
31 public Table<DataTypeTest> DataTypeTest { get { return this.GetTable<DataTypeTest>(); } }
32 public Table<Doctor> Doctor { get { return this.GetTable<Doctor>(); } }
33 public Table<GrandChild> GrandChild { get { return this.GetTable<GrandChild>(); } }
34 public Table<LinqDataTypes> LinqDataTypes { get { return this.GetTable<LinqDataTypes>(); } }
35 public Table<Parent> Parent { get { return this.GetTable<Parent>(); } }
36 public Table<Patient> Patient { get { return this.GetTable<Patient>(); } }
37 public Table<Person> Person { get { return this.GetTable<Person>(); } }
38
39 #region FreeTextTable
40
41 public class FreeTextKey<T>
42 {
43 public T Key;
44 public int Rank;
45 }
46
47 class FreeTextTableExpressionAttribute : TableExpressionAttribute
48 {
49 public FreeTextTableExpressionAttribute()
50 : base("")
51 {
52 }
53
54 public override void SetTable(SqlTable table, MemberInfo member, IEnumerable<Expression> expArgs, IEnumerable<ISqlExpression> sqlArgs)
55 {
56 var aargs = sqlArgs.ToArray();
57 var arr = ConvertArgs(member, aargs).ToList();
58 var method = (MethodInfo)member;
59 var sp = new MsSql2008SqlProvider();
60
61 {
62 var ttype = method.GetGenericArguments()[0];
63 var tbl = new SqlTable(ttype);
64
65 var database = tbl.Database == null ? null : sp.Convert(tbl.Database, ConvertType.NameToDatabase). ToString();
66 var owner = tbl.Owner == null ? null : sp.Convert(tbl.Owner, ConvertType.NameToOwner). ToString();
67 var physicalName = tbl.PhysicalName == null ? null : sp.Convert(tbl.PhysicalName, ConvertType.NameToQueryTable).ToString();
68
69 var name = sp.BuildTableName(new StringBuilder(), database, owner, physicalName);
70
71 arr.Add(new SqlExpression(name.ToString(), Precedence.Primary));
72 }
73
74 {
75 var field = ((ConstantExpression)expArgs.First()).Value;
76
77 if (field is string)
78 {
79 arr[0] = new SqlExpression(field.ToString(), Precedence.Primary);
80 }
81 else if (field is LambdaExpression)
82 {
83 var body = ((LambdaExpression)field).Body;
84
85 if (body is MemberExpression)
86 {
87 var name = ((MemberExpression)body).Member.Name;
88
89 name = sp.Convert(name, ConvertType.NameToQueryField).ToString();
90
91 arr[0] = new SqlExpression(name, Precedence.Primary);
92 }
93 }
94 }
95
96 table.SqlTableType = SqlTableType.Expression;
97 table.Name = "FREETEXTTABLE({6}, {2}, {3}) {1}";
98 table.TableArguments = arr.ToArray();
99 }
100 }
101
102 [FreeTextTableExpressionAttribute]
103 public Table<FreeTextKey<TKey>> FreeTextTable<TTable,TKey>(string field, string text)
104 {
105 return this.GetTable<FreeTextKey<TKey>>(
106 this,
107 ((MethodInfo)(MethodBase.GetCurrentMethod())).MakeGenericMethod(typeof(TTable), typeof(TKey)),
108 field,
109 text);
110 }
111
112 [FreeTextTableExpressionAttribute]
113 public Table<FreeTextKey<TKey>> FreeTextTable<TTable,TKey>(Expression<Func<TTable,string>> fieldSelector, string text)
114 {
115 return this.GetTable<FreeTextKey<TKey>>(
116 this,
117 ((MethodInfo)(MethodBase.GetCurrentMethod())).MakeGenericMethod(typeof(TTable), typeof(TKey)),
118 fieldSelector,
119 text);
120 }
121
122 #endregion
123 }
124
125 [TableName(Name="BinaryData")]
126 public partial class BinaryData
127 {
128 [Identity, PrimaryKey(1)] public int BinaryDataID { get; set; } // int(10)
129 public byte[] Stamp { get; set; } // timestamp
130 public byte[] Data { get; set; } // varbinary(1024)
131 }
132
133 [TableName(Name="Child")]
134 public partial class Child
135 {
136 [Nullable] public int? ParentID { get; set; } // int(10)
137 [Nullable] public int? ChildID { get; set; } // int(10)
138 }
139
140 [TableName(Name="DataTypes")]
141 public partial class DataTypes
142 {
143 [Nullable] public int? ID { get; set; } // int(10)
144 [Nullable] public decimal? MoneyValue { get; set; } // decimal(10,4)
145 }
146
147 [TableName(Name="DataTypeTest")]
148 public partial class DataTypeTest
149 {
150 [Identity, PrimaryKey(1)] public int DataTypeID { get; set; } // int(10)
151 [Nullable ] public byte[] Binary_ { get; set; } // binary(50)
152 [Nullable ] public bool? Boolean_ { get; set; } // bit
153 [Nullable ] public byte? Byte_ { get; set; } // tinyint(3)
154 [Nullable ] public byte[] Bytes_ { get; set; } // varbinary(50)
155 [Nullable ] public char? Char_ { get; set; } // char(1)
156 [Nullable ] public DateTime? DateTime_ { get; set; } // datetime(3)
157 [Nullable ] public decimal? Decimal_ { get; set; } // decimal(20,2)
158 [Nullable ] public double? Double_ { get; set; } // float(53)
159 [Nullable ] public Guid? Guid_ { get; set; } // uniqueidentifier
160 [Nullable ] public short? Int16_ { get; set; } // smallint(5)
161 [Nullable ] public int? Int32_ { get; set; } // int(10)
162 [Nullable ] public long? Int64_ { get; set; } // bigint(19)
163 [Nullable ] public decimal? Money_ { get; set; } // money(19,4)
164 [Nullable ] public byte? SByte_ { get; set; } // tinyint(3)
165 [Nullable ] public float? Single_ { get; set; } // real(24)
166 [Nullable ] public byte[] Stream_ { get; set; } // varbinary(50)
167 [Nullable ] public string String_ { get; set; } // nvarchar(50)
168 [Nullable ] public short? UInt16_ { get; set; } // smallint(5)
169 [Nullable ] public int? UInt32_ { get; set; } // int(10)
170 [Nullable ] public long? UInt64_ { get; set; } // bigint(19)
171 [Nullable ] public string Xml_ { get; set; } // xml(-1)
172 }
173
174 [TableName(Name="Doctor")]
175 public partial class Doctor
176 {
177 [PrimaryKey(1)] public int PersonID { get; set; } // int(10)
178 public string Taxonomy { get; set; } // nvarchar(50)
179
180 // FK_Doctor_Person
181 [Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=false)]
182 public Person Person { get; set; }
183 }
184
185 [TableName(Name="GrandChild")]
186 public partial class GrandChild
187 {
188 [Nullable] public int? ParentID { get; set; } // int(10)
189 [Nullable] public int? ChildID { get; set; } // int(10)
190 [Nullable] public int? GrandChildID { get; set; } // int(10)
191 }
192
193 [TableName(Name="LinqDataTypes")]
194 public partial class LinqDataTypes
195 {
196 [Nullable] public int? ID { get; set; } // int(10)
197 [Nullable] public decimal? MoneyValue { get; set; } // decimal(10,4)
198 [Nullable] public DateTime? DateTimeValue { get; set; } // datetime(3)
199 [Nullable] public bool? BoolValue { get; set; } // bit
200 [Nullable] public Guid? GuidValue { get; set; } // uniqueidentifier
201 [Nullable] public byte[] BinaryValue { get; set; } // varbinary(5000)
202 [Nullable] public short? SmallIntValue { get; set; } // smallint(5)
203 }
204
205 [TableName(Name="Parent")]
206 public partial class Parent
207 {
208 [Nullable] public int? ParentID { get; set; } // int(10)
209 [Nullable] public int? Value1 { get; set; } // int(10)
210 }
211
212 [TableName(Name="Patient")]
213 public partial class Patient
214 {
215 [PrimaryKey(1)] public int PersonID { get; set; } // int(10)
216 public string Diagnosis { get; set; } // nvarchar(256)
217
218 // FK_Patient_Person
219 [Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=false)]
220 public Person Person { get; set; }
221 }
222
223 [TableName(Name="Person")]
224 public partial class Person
225 {
226 [Identity, PrimaryKey(1)] public int PersonID { get; set; } // int(10)
227 public string FirstName { get; set; } // nvarchar(50)
228 public string LastName { get; set; } // nvarchar(50)
229 [Nullable ] public string MiddleName { get; set; } // nvarchar(50)
230 public char Gender { get; set; } // char(1)
231
232 // FK_Doctor_Person_BackReference
233 [Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=true)]
234 public Doctor Doctor { get; set; }
235
236 // FK_Patient_Person_BackReference
237 [Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=true)]
238 public Patient Patient { get; set; }
239 }
240 }
241
242 namespace Linq.OverWCF
243 {
244 public partial class DataModel
245 {
246 public DataModel() : base(
247 new NetTcpBinding(SecurityMode.None)
248 {
249 MaxReceivedMessageSize = 10000000,
250 MaxBufferPoolSize = 10000000,
251 MaxBufferSize = 10000000,
252 CloseTimeout = new TimeSpan(00, 01, 00),
253 OpenTimeout = new TimeSpan(00, 01, 00),
254 ReceiveTimeout = new TimeSpan(00, 10, 00),
255 SendTimeout = new TimeSpan(00, 10, 00),
256 },
257 new EndpointAddress("net.tcp://localhost:1234/LinqOverWCF"))
258 {
259 }
260 }
261 }