linq-to-entities

C# MVC2 Jqgrid - what is the correct way to do server side paging?

人走茶凉 提交于 2019-12-20 04:15:07
问题 I have a jqgrid where the database table has a few thousand rows, but the jqrid shows only 15 at a time. It should be displaying very quickly (it doesnt take long to query 15 rows). But instead it takes 10 - 20 seconds, which indicates to that it is retrieving the entire table each time. The grid is defined like this: $("#Products").jqGrid({ url: url, mtype: "get", datatype: "json", jsonReader: { root: "Rows", page: "Page", total: "Total", records: "Records", repeatitems: false, userdata:

Ordering sub-items within ordered items in a Linq to Entities Query

只愿长相守 提交于 2019-12-20 03:56:13
问题 I have a few tables, Listings, ListingImages and a few others related to Listings. ListingImages is related to Listings so that you can have many ListingImages per Listing. When I query this table I do; IQueryable<Listing> ListingToSendToView = (from x in DBEntities.ListingSet.Include("ListingImages") .Include("OtherTables") where x.Listing.ID == (int)LID orderby x.ID descending select x).First(); Now this is fine. However, I now want to sort the ListingImages independently within each

Projection in Linq to SQL and Linq to Entities

余生颓废 提交于 2019-12-20 03:40:54
问题 I am trying to get the columns dynamically. In NHibernate i can do this: var list = _session.CreateCriteria(typeof(Person)) .SetProjection(Projections.ProjectionList() .Add(Projections.Property("FirstName")) .Add(Projections.Property("LastName")) .Add(Projections.Property("Jersey")) .Add(Projections.Property("FortyYard")) .Add(Projections.Property("BenchReps")) .Add(Projections.Property("VertJump")) .Add(Projections.Property("ProShuttle")) .Add(Projections.Property("LongJump")) .Add

Dynamic entity in EF1/change model in runtime/add property dynamicaly

强颜欢笑 提交于 2019-12-20 02:56:05
问题 I want to give users the possibility to dynamically add new columns at the runtime. I am using the Entity framework v1 ... I did manage to read as xml and then change ssdl , csdl and msl files and construct new workspace and new object context... But the problem is when i dynamically add new columns in EF model the underlying object is not changed, of course. How to get the data from model without having concrete entity ? Anonymous type or DBDataRecord would be just fine... Or even some new

Get subset of entity navigation properties

不问归期 提交于 2019-12-20 02:52:19
问题 I have User entity and related to many product entity , I need a way to get the user entity with subset of its products not all the products. var user = User.Include("Product").ToList(); // it returnes all the products. I need a way to return the User with only 15 products. Thanks in advance... 回答1: You can't filter or affect in some other way data which are loaded into navigation properties. When you use eager loading or lazy loading of related entities, then EF just does LEFT OUTER JOIN

Insert a copy of existing row using Linq to Entities [closed]

冷暖自知 提交于 2019-12-20 02:28:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am using entity framework. I have a table with auto generated primary key and lot of foriegn key relationship with other master data tables. We need a copy functionality, wherein we can select any existing row from the table and insert that as a copy in the same table. I need to copy all the fields, but it

Convert string to int in LINQ to Entities?

你说的曾经没有我的故事 提交于 2019-12-20 01:33:46
问题 I have to convert a string value to int , but it seems LINQ to Entities does not support this. For the following code, I am getting an error. var query = (from p in dc.CustomerBranch where p.ID == Convert.ToInt32(id) // here is the error. select new Location() { Name = p.BranchName, Address = p.Address, Postcode = p.Postcode, City = p.City, Telephone = p.Telephone }).First(); return query; LINQ to Entities does not recognize the method ' Int32 ToInt32 (System.String) ', and this method can

Entity Framework: how to do correct “Include” on custom type

别说谁变了你拦得住时间么 提交于 2019-12-20 00:56:42
问题 Suppose we have 2 types, mapped to a Database via EF 4. Schedule 1.....1 Visit Also, we have third custom view type public class ScheduleView { public Schedule Schedule { get; set; } public Visit Visit { get; set; } } So we can write the join query var query = Context.Schedule.Join(Context.Visit ,/*Schedule join key definition*/,/*Visit join key definition*/, (scheduleView, visit) => new ScheduleView {Schedule = scheduleView, Visit = visit}) The problem is that I need to load also Patient

Entity Framework: how to do correct “Include” on custom type

北城余情 提交于 2019-12-20 00:52:52
问题 Suppose we have 2 types, mapped to a Database via EF 4. Schedule 1.....1 Visit Also, we have third custom view type public class ScheduleView { public Schedule Schedule { get; set; } public Visit Visit { get; set; } } So we can write the join query var query = Context.Schedule.Join(Context.Visit ,/*Schedule join key definition*/,/*Visit join key definition*/, (scheduleView, visit) => new ScheduleView {Schedule = scheduleView, Visit = visit}) The problem is that I need to load also Patient

Export to csv - Linq query

烈酒焚心 提交于 2019-12-19 21:55:37
问题 I have a class in linq that query db table like this, and the question is: How do I export that data to csv? I have tried link suggested and I am using linq2csv and still want to know how to get column by their order? thanks! var usr = from usr in db.User select new { usr.UserName, usr.Dept, usr.Name) MainListView.DataSource = usr; MainListView.DataBind(); CsvFileDescription outputFileDescription = new CsvFileDescription { SeparatorChar = ',', FirstLineHasColumnNames = true, FileCultureName =