I have IQueryable Products. now i want to add new product to this IQueryable object. so how do i do this?
-
I've never tried this, but try products.Union(moreProducts).
-
IQueryable doesn't have any methods for adding. See MSDN.
-
The IQueryable interface does not itself provide operations to add to the set of items. Are you using an ORM? Which one? Microsoft's Entity Framework implements IQueryable via the System.Data.Linq.Table<TEntity> class, which also has methods for adding entities (Attach, AttachAll).
Vikas : i am not using M-E-F. & thanks for reply i got the answer. -
You are going to have to cast back to the type that is implementing IQueryable.
-
IQueryable doesn't provide any guarantee of having a means to add items; In order to add items, you will need access to the data store behind the IQueryable. If you are using Linq to SQL, this would be the table. Your code in that case would look like DataContext.GetTable().InsertOnSubmit(aProduct).
0 comments:
Post a Comment