I'm new in wpf. My main problem is to understand how DataGrid works with its datacontext. It would help me a lot because I don't know how to make a universal paging usercontrol for all my datagrids in the projects for different database tables. DataGrid converts received DataContext from object to some kind of list. How it is implemented...
I have this really strange problem where my entity framework query isn't enumerating correctly.
The SQL Server table I'm using has a table with a Sku field, and the column is "distinct". It isn't a key, but it doesn't contain any duplicate values. Using actual SQL with where, distinct and group by cluases I have confirmed this.
Howev...
I have 2 Entities "UserProfile" and "Agent", they are 1-many relationship. I want to do a query to get a list of Agents by giving the userProfileEntityKey. When I run it, I got this "The specified type member 'EntityKey' is not supported in LINQ to Entities" error.
public IQueryable<Agent> GetAgentListByUserProfile(EntityKey userProfil...
Hi I started building apps with this technology and I am facing a weird problem... on some machines I need to add theese lines to the app.config to get to work:
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MyS...
This has probably been answer already but I am trying to return the primary key after inserting a record to the database. Does anyone know how this is accomplish after the record has been created?
...
Hi this seems like it should work,
from something in collectionofsomestuff
select new SelectListItem(){Text = something.Name, Value = something.SomeGuid.ToString(), Selected = false};
When I try to do this it doesn't work give me error
LINQ to Entities does not recognize the method 'System.String ToString()' method, and thi...
HI, I'm using Linq To Entities and I'd like to convert this
return db.Products
.Where(p => p.idUser.Equals(id) &&
p.Category.Genre.Any(g => g.visible))
into something like
Func<Genre, bool> expr = g => g.visible
return db.Products
.Where(p => p.idUser.Equals(id) &&
p.Cate...
I want to separate out often used expressions in linq queries. I'm using Entity Framework 4 and also LINQKit but I still don't know how I should do it the right way. Let me give you an example:
Article article = dataContainer.Articles.FirstOrDefault(a => a.Id == id);
IEnumerable<Comment> comments =
(from c in article.Comments
wher...
For example
a = datacontext.customers.FirstOrDefaul();
b = datacontext.customers.Skip(1).FirstOrDefaul();
a.name="name1";
b.Name="name2";
When i call datacontext.SubmitChanges(), Two object updated. I don't want this.
I need only Update a object. How do it?
EDIT
WPFWindow windowA=new WPFWINDOW()
windowA.DataContext=a;
windowA.Sh...
Hello,
We want to set up a directory of all the organizations working with us. They are incredibly diverse (government, embassy, private companies, and organizations depending on them ). So, I've resolved to create 2 tables. Table 1 will treat all the organizations equally, i.e. it'll collect all the basic information (name, address, ph...
My main entity is called [Contract]. Contract has a many 2 many relationship w/ [Service].
When I query for a list of Contracts I grab the 1st Service available like this:
IQueryable<Contract> q = ctx.Contracts.Skip(startRow - 1).Take(pgSize);
q.Select(c =>
new ContractSearchResult()
{
ContractID = c.Contra...
Hello Everyone,
I am trying to find the best way to build a dynamic linq query and populate a list. The user will have about five different fields in which they can choose to filter on. Currently i have the following code:
List<TBLPROMOTION> promotionInfo = null;
bool active = true;
int storeId = 1
using (WSE ...
I have the following SQL query:-
select distinct * from dbo.Profiles profiles
left join ProfileSettings pSet on pSet.ProfileKey = profiles.ProfileKey
left join PlatformIdentities pId on pId.ProfileKey = profiles.Profilekey
I need to convert it to a LinqToEntities expression. I have tried the following:-
from profiles in _dbContext....
Hello everyone,
I am trying to figure out the best way of getting the record count will incorporating paging. I need this value to figure out the total page count given a page size and a few other variables.
This is what i have so far which takes in the starting row and the page size using the skip and take statements.
promotionInfo = ...
using(SampleEntities entities = new SampleEntities()) {
var userMap = from ad in entities.SampleGroupsSet
from uid in distinctUserIDs
where ad.ShortUserID.ToLower() == uid.ToLower()
select new {shortID = uid, longID = ad.UserID};
string userID = "sampleId";
var longIDs = from map in userMap
...
Hello Everyone,
I am trying to write a linq query that will only return certain columns from my entity object into a list object.
Below is my code which produces an error(can't implicitly convert a generic list of anonymous types to a generic list of type TBLPROMOTION):
IQueryable<TBLPROMOTION> matches = webStoreContext.TBLPROMOTION....
If given a an entity with a datetime as a string... what are my options to filter the data with Linq to Entities on the date?
It does not seem to support me doing datetime conversions.
Basically, I want to accomplish:
var filtered = from item in entities.itemsSet
where Convert.ToDateTime(shift.starttime) >...
I recently switched from using Linq to Sql to the Entity Framework. One of the things that I've been really struggling with is getting a general purpose IQueryable extension method that was built for Linq to Sql to work with the Entity Framework. This extension method has a dependency on the Like() method of SqlMethods, which is Linq to...
I have a table with two columns, GroupId and ParentId (both are GUIDS). The table forms a hierarchy so I can look for a value in the “GroupId” filed, when I have found it I can look at its ParentId. This ParentId will also appear in the GroupId of a different record. I can use this to walk up the hierarchy tree from any point to the root...
Hello! I write a simple OLAP viewer for my web-site. Here are the classes (abstract example):
Employee
{
ID;
Name;
Roles[]; //What Employee can do
}
Order
{
Price;
Employee Manager;
Employee Executive; //Maybe wrong english. The person which perform order
}
Employee can be Manager and Executiv...