Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create class, wich has got all the fields you need: id, foo, bar, etc. and add to it Calculated field, then just modify your query:</p> <pre><code>var query = from A in context.A join B in context.B on A.ID equals B.ID join C in context.C on A.ID2 equals C.ID2 where A.endtime&gt; endtime &amp;&amp; A.Chk.StartsWith("320") select new YourNewClass { Foo = A.foo, Bar = B.bar, ... , Calculated = A.foo * B.bar }; </code></pre> <p>EDITED: if you have got a lot of fields, you can use <a href="http://bengtbe.com/blog/2009/04/14/using-automapper-to-map-view-models-in-asp-net-mvc/" rel="nofollow">automapper</a></p> <p>Here is an example. Say, you have got class User from your DB and you have got class UserModel, in which you added a field FullName which constist from fields Name and Surname. So you want to create an object UserModel from object User but not to copy all the fields exclicitly. That's how you can do it:</p> <pre><code>class Program { static void Main(string[] args) { User u = new User { Name = "My", Surname = "Name" }; Mapper.CreateMap&lt;User, UserModel&gt;().ForMember(dest =&gt; dest.FullName, o =&gt; o.MapFrom(src =&gt; string.Format("{0} {1}", src.Name, src.Surname))); UserModel um = Mapper.Map&lt;User, UserModel&gt;(u); Console.WriteLine(um.FullName); } } public class User { public string Name { get; set; } public string Surname { get; set; } } public class UserModel { public string Name { get; set; } public string Surname { get; set; } public string FullName { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload