I'm trying to dynamically build a LINQ query for LINQ to Entities so that I can avoid repeating the same function twice.
Here is what I'm trying to do:
private IUser GetOrUpdateUser(Predicate<IUser> filter, Func<IIdentityProvider, UserRecord> fetch)
{
var user = (from u in this.adapter.Users
where filter(u)
...
How to do this in linq to entities in one query?
SELECT avg(Column1), avg(Column2), ... from MyTable
where ColumnX = 234
??
...
I have a table and for the sake of the example lets say it has three columns: Name, DateAdded, Note. In this table there will be multiple records with the same name. I need a linq where clause that will get me a result set with the most recent record for each name.
So if I had the following information:
Name, DateAdded, Note
Alpha, 1/1...
Hello community,
i'have following scenario:
Tables and Columns (Database Type: Microsoft Sql Server 2005):
Table: Entries
EntryID
... other unimportant columns
Table: Attributes
AttributeID
Table: EntryAttributes
EntryID [Releation To: Entries->EntryID]
AttributeID [Releation To: Attributes->AttributeID]
So, how can i sele...
How can this query be transform to linq
SELECT materialId, SUM(totalAmount) as quantity FROM Inventory
It's the sum part that I don't know how...
query = from inv in context.Inventory
select new MaterialQuantity()
{
MaterialId = inv.materialId,
...
I have an entity with a foreign key relationship to an asp.net membership provider users table.
This portion of the model looks like this:
I can't seem to assign the foreign key relationship when inserting the Users table record, the record containing the foreign key to the aspnet_Users table. I keep getting the error:
An item w...
Hi Experts,
Does AutoMapper supports linq to entities (framework 1.1).
Is there any sample project available.
Also using linq to SQL when I try convert from POCO to entity object, it fails saying AutomapperTest.Test.Account
Help will be appreciated.
Regards
Parminder
...
Developing a .net library based on an industry standard. The standard includes data structures and an api for interacting with a server.
I am considering adding a Linq friendly implementation, and to try to either implment or emulate Linq to Entities. The obvious difference is the API is used for CRUD operations, instead of a database ...
Is it possible to create a dynamic query with Entity Framework. I Have 18 tables, Each of them has the same structures. How can I create a dynamic query to reuse the same query for each tables. I would like to have a generic query for Create Read Update Delete.
The read contains the same "Where" Clause.
Thanks for your help.
...
Ok.this is just making me frustrated...
Here is step by step of what I am trying to do (& not able to)
I am calling WCF service hosted in a SharePoint 2010 site from a silverlight app in same domain (So no cross doman I guess).
I use Linq to Sharepoint for querying the DB.
I am having a list "machines" in Sharepoint 2010 that is havin...
Hi folks
Im new to MVC, EF4 and Linq, so forgive my ignorance
If im using a Linq Query to return data to pop into a viewmodel, I can include tables with a relation and get to the data without relying on lazy loading.
However I have a problem eager loading data that isnt in a directly relatede table. e.g I have fixtures that relate to ...
I'm trying to do a simple update but I cannae for the life of me work out what I am doing wrong.
I have the following code which currently is not working - I'm getting not all code paths return a value.
public List<tblWeight> UpdateFeedback(string memberid, string locationid, int prikey, string feedback)
{
MyEntities updatefee...
Ok, got my query going, up and running but it doesn't appear that I have got it working correctly!!
My query is as follows:
MyEnt updatefeedback = new MyEnt();
tblWeight newfeedback = (
from weight in updatefeedback.tblWeights
where weight.MemberId == memberid
where weight.LocationId == locationid
where weight.PriKey =...
I have been looking everywhere and can not seem to solve this. I have the following linq to data entities that sometime returns an empty set. But I can not seem to test for the empty set?
IEnumerable<string> xrefLineItems = from xref in db.wysLkupItemCrossRefs
where xref.EndPointC...
I have a query that looks like this:
var results = from person
where <here I need to do something like if person is of type
Employee, call person.GetSalary() > 100000 but if the person is of type Contractor, I need to execute
several lines of code before doing a person.GetSalary() > 100000
sele...
I have a function that returns the following type:
IEnumerable<IGrouping<String, ExportTransaction>>
In this function I create a list of the following type, using a linq expression:
IEnumerable<ExportTransaction>
The Linq code looks like this:
IEnumerable<ExportTransaction> transactions = ctx.ExportTransactions
...
I'm just starting to learn Entity Framework 4, and am a bit confused about how pivot tables enter the mix. Case in point: I'm migrating a video game review site from PHP 5/Kohana framework to ASP.NET MVC 2. I have a few pivot tables to map the many-to-many relationships I have. Example:
Video games can be available for several platfo...
Hello,
I've been trying to implement a custom ORM for our project and am interested to learn how LINQ to SQL or Entity Framework lazy load objects.
I read some about EntitySet and realized it has a Load() method. Does anyone know how exactly Load works? I'm assuming it should have a reference to DataContext (or ObjectContext in EF) t...
I am just getting started with Entity Framework. The problem i face is since it is an ORM it models everything as real world entities. Hence, if i fetch a parent record it's child records are fetched automatically. If i have 1000's of child records all of them get fetched even though i may not need them currently. This i think is very in...
Linq to Entities uses the ObjectQuery which implements IQueryable. I normally use the IQueryable methods to filter through my data but today I needed to create a special LIKE statement. The framework keeps thinking its smart and "escaping" my wildcard "%" with the tilde which rendered my special LIKE statement null and void. So after dig...