c# - Programmatically load a LINQ2SQL partial class -
I am working on a project that allows a user to add time to the task. In the Task I have an area for the estimated period, and I think that the time added in the tenure can get me the reality.
I have a LINQ2SQL class for work, as well as additional working classes (by partial use).
I still have the following for my query:
Public IQueryable & lt; Work & gt; GetTasks (Task Controller Criteria) {// set option curious load child object (s) var opts = new System.Data.Linq.DataLoadOptions (); Opts.LoadWith & lt; Work & gt; (Line = & gt; line.product); Opts.LoadWith & lt; Work & gt; (Line = & gt; line.assiditusurizer); Opts.LoadWith & lt; Work & gt; (Line = & gt; line customers); Opts.LoadWith & lt; Work & gt; (Line = & gt; line.stage); Db.LoadOptions = opts; IQueryable & LT; Tasks & gt; Query = db Task; If (criteria. Project ID. (.have) query = query. Where (line = & gt; line.product id == criteria.product id); If (criteria.StageId.HasValue ()) query = query.Where (line =>; row.StageId == criterion.StageId); If (Criterion Status. HasValue) query = query.Where (line = & gt; line position == (int) criteria.); Var result = query. Selection (line = & gt; line); Return result; }
What would be the best way to get on ActualDuration, which is the sum of units in the workgroup table?
Add a property to your task partial square, like this:
< Code> public int real depression {your detactor DB = new your datacontact (); Return db.Task.durations.Where (t = & gt; t.task_id == this.id). Yoga (T => calibration of T.); }}
Then you can refer to the actual period as a work. Reality
Update: You asked how to do this with partial orbit. Of course this hit the database again. The only way to get data from a database that you do not know yet is to kill that database. If you need to avoid the reasons for the execution because of this, write a subquery or SQL function, which calculates the actual duration, and uses the function that contains the calculation value. Now, the function / query must still collect the time recorded for each work line in the result set, so it will still be performance-intensive if you have a very large work table and performance problems, on the task table Keep running matches. I think partial classroom solutions are also good for many 100,000 tasks. You rarely re-find once in a large number, I would think grid control with paging only receives one page at that time.
Comments
Post a Comment