iqueryable

ASP.NET MVC4: IQueryable does not contain a definition for 'Add'

牧云@^-^@ 提交于 2019-12-13 00:45:16
问题 I have tried to make an MVC news system. I started by the use a pluralsight tutorial which was used to create a department with employees. I changed the idea to fit my own purposes, changing the departments to "category" and employees to "newspost". This all works out fine, but now I want to remove the categories, since I don't need categories for my news system. But I can't add to the database using entityframework when I do this. I have an interface for the datasource that looks like this:

Entity Framework 5, Code First, Full Text Search but IQueryable via CreateQuery?

旧巷老猫 提交于 2019-12-12 16:01:49
问题 I am using .NET 4.5 and EF 5 with Code First approach and now I need to implement Full Text Search. I have already read a lot about it and so far my conclusions are: Stored procedures nor Table Value Functions can not be mapped with Code First. Still I can call them using dynamic sql dbContext.Database.SqlQuery<Movie>(Sql, parameters) But this returns IEnumerable and I want IQueryable so that I can do more filtering before fetching the data from db server. I know I can send those parameters

IQueryable<a> to ObservableCollection<a> where a = anonymous type

∥☆過路亽.° 提交于 2019-12-12 08:35:05
问题 I want the datacontext of my listview to be binded to an observable collection. Right now I have: // CurrentEmploye = some employee Entities.DatabaseModel m = new Entities.DatabaseModel(); var q = from t in m.TimeSheet join emp in m.Employees on t.idEmployee equals emp.id where emp.id == CurrentEmploye.id select new { firstName = emp.firstName, lastName = emp.lastName, position = emp.position, clockInDate = t.clockInDate, clockOutDate = t.clockOutDate, }; listView1.DataContext = q; that code

disadvantages of using IQueryable !

我的未来我决定 提交于 2019-12-12 02:28:50
问题 Is there are any performance issues related to using IQueryable ? Besides, if I use a cursor instead of using IQueryable (is that better) . IQueryable vs IEnumerable vs IList ? I use MongoDB as my database . Thank you 回答1: I don't know how the MongoDB C# binding works, but describe how it usually works: When using IQueryable an expression tree is constructed, then translated into a format the database can understand and then executed in the database-server. This typically has a small overhead

NHibernate + IQueryable access subtype property in where

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 01:41:51
问题 I've got problem with NHibernate v3.2.0, and following query: class DocumentBase {} class Requisition: DocumentBase {} class Order: DocumentBase {} Repository.GetAll<DocumentBase>() .Where(d => (d is Requisition) && ((Requisition)d).ProductItem != null) Base query is designed to list all documents, but there is also possibility to filter this documents by type (and quasi-type, which is for example document without product). In code above there is only one condition, but predicate can be more

Convert Entity with navigation property to DTO using IQueryable

女生的网名这么多〃 提交于 2019-12-12 00:38:49
问题 Suppose I have following entities and dtos public class Country { public List<NameLocalized> NamesLocalized; public CountryData Data; } public class NameLocalized { public string Locale; public string Value; } public class CountryData { public int Population; } public class CountryDto { public String Name; public CountryDataDto Data; } public class CountryDataDto { public int Population; } I need to convert Country to CountryDto (and ideally, I want to make a single query to the database). I

DataGridView delete row when DataSource is List<myClass>

假如想象 提交于 2019-12-11 07:15:35
问题 On my DataGridView I have set the AllowUserToDeleteRows to True. When I set my DataGridView 's DataSource to an IQueryable var dc = new Data.CustomersDataContext(); var q = dc.Customers; dataGridView1.DataSource = q; I can delete rows from it, but when I set it to a List<T> var dc = new Data.CustomersDataContext(); var l = dc.Customers.ToList(); dataGridView1.DataSource = l; I can no more delete rows (nothing happens when I press delete button) How can I keep my DataSource as a List<T> and

Exposing EntityFramework 4 entities as IList instead of IObjectSet

依然范特西╮ 提交于 2019-12-11 07:08:45
问题 I have a 'Customer' POCO entity within my Entity Framework 4 project. I want to expose my Customer entities to my upper layers as a generic list rather than an ObjectSet. I have an IUnitOfWork interface which looks as follows: public interface IUnitOfWork { string Save(); IList<Customer> Customers { get; } } Down at my Entity Framework DAL (which implements the above interface) I have the following: public class EntityContainer : ObjectContext, IUnitOfWork { private IObjectSet<Customer>

Extension methods for converting IQueryable<T> and IEnumerable<T> to ReadOnlyCollection<T>

和自甴很熟 提交于 2019-12-11 04:29:25
问题 How to write extension methods for converting IQueryable<T> and IEnumerable<T> to ReadOnlyCollection<T> ? Thanks 回答1: public static ReadOnlyCollection<T> AsReadOnlyCollection<T>(this IEnumerable<T> source) { if(source == null) throw new ArgumentNulLException("source"); IList<T> list = source as IList<T> ?? source.ToList(); return new ReadOnlyCollection<T>(list); } Note that there is no such thing as "converting" an IEnumerable<T> in this case (as with all other methods in the LINQ stack), you

Cannot convert expression type 'NHibernate.IQueryOver<T,T>' to return type 'System.Linq.IQueryable<T>'

£可爱£侵袭症+ 提交于 2019-12-11 03:28:51
问题 I'm sure I'm doing this wrong, but I've been picking at it for a while. I'm trying to implement an IRepository Find method, and I just can't seem to work out how. Any help would be greatly appreciated! The following code gives me the red squiggly line with the error message posted as the question. IQueryable<T> IRepository<T>.Find(Expression<Func<T, bool>> predicate) { return sessionManager.OpenSession().QueryOver<T>().Where(predicate); } 回答1: You have to use .Query<T>() extension method