I'd like to expose a method over WCF something like GetEmployees(EmployeeColumn orderby), that returns a list of employees in an order.
I don't really want to create an enum EmployeeColumn that contains all possible column so the user can choose.
What do you suggest? I'd like to achieve this using linq-to-entities.
...
I am getting this error and I have collection of anonymous Datarows and each item contains two datarows. How to cast this?
Unable to cast object of type 'WhereSelectEnumerableIterator`2[VB$AnonymousType_0`2[System.Data.DataRow,System.Data.DataRow],VB$AnonymousType_0`2[System.Data.DataRow,System.Data.DataRow]]' to type 'System.Data.Enume...
I am created pre-generated views for my EDMX using VS 2008, .NET 3.5 and Entity framework.
I have generated using the t4 templates mentioned here and got my mymodel.views.cs file. It's around 40 mb is size.
Added the views.cs file to my web application and my web service. When i build the apps, the webservice would build without any er...
I create a EDM using my database and saw that while it was able to make relations like
Customers.First().Orders
there is nothing like
Customer.First().Orders.FindOrderByOrderID()
Customer.First().Orders.FindOrderByOrderName()
etc.
Maybe I was expecting it to be like that and that's how it doesnt work
and I will probably just have...
I have a EDM that was wizard generated from an SQL 2005 Express database. For example, I have a table named Projects with a relationship to a table named People. Projects have two relationships on the People table primary key as foreign key in the People table (ChamipionID and LeaderID).
I have cleaned up all of the names for the Enti...
I need to implement 3 public methods that all rely on the same initial join. Would a solution like the one described below work?
The code below is an example, the real stuff is much more complicated, that's why I want to reuse it.
private Tuple<Customer,Order> GetCustomerOrders()
{
from c in customers
join o in orders
o...
I'm trying to query the Northwind database relationship between Categories and Products, where each category has multiple products...
Im looking for a query that will return the 1 category with the highest number of products in it.
This is as far as I've gotten
var results = from c in entities.CategorySet
...
I have this LINQ statement
Dim Demo = From d In DBDataTable.AsEnumerable _
Select id = d.Field(Of Integer)("id"), _
Colun = d.Field(Of Object) (_column2), _
Col3 = d.Field(Of Object)(_column3), _
Col4 = IIf(_Col4 <> -1, d.Field(Of Object)(_Col4), Nothing)
Is there any wa...
I need to replicate a T-SQL statement that has an inner select, using LINQ:
SELECT *,
CustomerTypes.Description as CustomerType,
(Select Min(Distinct DocumentStatistics.StatDateTime) As LastStatCheck
From DocumentStatistics
Where DocumentStatistics.CustomerId = Customers.CustomerId) As LastStatCheck
FROM Customers
INNER JOIN Custome...
In my database there's a datetime column "Created" with default value getutcdate(). I would like my EF datacontext to generate an insert query that doesn't set this column, and fetch the resulting value. Is there a way to do this?
I tried setting StoreGeneratedPattern to either None, Identity or Computed, I get an exception that DateTim...
Is it possible to define DateTime properties in entity objects that are of Kind == DateTimeKind.Utc by using either the .edmx file, or a t4 template?
When possible using t4, please describe how to change the property. Currently the property gets generated as:
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[Dat...
I have a UI that presents a number of checkboxes to the user, and for each one that is checked, I need to create an entry in a mapping table.
LookupTable <- MapTable -> DataTable
I have a custom binder for DataTable, but can't figure out how to get it to create the MapTable objects.
Is this possible? Using asp.net MVC 1.0 and LINQ t...
I'm trying to understand why, sometimes, my sub-objects disappear.
In my List view, I have the standard
<% foreach (var item in Model)
and when I inspect the item and the model, I can see that item.Map has a couple of elements.
In fact, in my List view I can do:
<% foreach (var map in item.Map)
<% Html.RenderPartial("MapView", ...
My classes are a DataModel, which uses ID as its PK, and a Map, which also has ID as a PK. Map has a FK to DataModel (DataModelID).
I have a partial view that I use from my DataModel list view as follows:
<% foreach (var map in Model.Map)
{ %>
<% Html.RenderPartial("MapEdit", map); %>
<% } %>
My MapEdit partial view looks lik...
Below is a rough and simplified code example of what I am trying to do and it is not working as expected. I am using Linq to Entity in case that matters.
Basically in the first loop with the DateClause's ends up returning nothing if I have two date clauses, works great with one date clause. In the TextClause's loop it seems to ignore...
Hi,
Iam working on sorting the grid remotely.
Iam using the folllowing query
SELECT value a, ROW_NUMBER() OVER (ORDER BY" + " " + SortExpression + ") As RowNumber FROM XSP_AssetList_V AS a WHERE a.AccountID = GUID'" + AccountID + "'";
is there any linq equivalanet for rownumber() over orderby()
but iam getting an error
System.Dat...
Put simply... in plain SQL I would do this:
SELECT * FROM [Products] WHERE [Description] LIKE '%[0-9]%'
In Linq to Entities I do this:
Products.Where(p => p.Description.Contains("[0-9]"))
But I end up with this:
-- Region Parameters
DECLARE @p0 NVarChar(8) SET @p0 = '%~[0-9]%'
-- EndRegion
SELECT ...
FROM [Products] AS [t0]
WHERE ...
I have been using LINQ to SQL for the last year and have had no problems. I decided that I wanted to experiment with the EntityFramework on a project where the requirement was to just return some raw data from several Views in a customer's database. I created the Entities model, included the Views, but when I wrote a query to return the ...
Good afternoon,
I have three entities (that concern this question)
Company (ID, etc..)
CompanyAddress (AddressID, CompanyID, Rank)
AddressDetails (AddressID, Street, City, State, Zip)
The reason Rank and company id aren't in the AddressDetails is because the address detas are shared with contacts via a ContactAddress entity.
Anyway, ...
I have a set of Entities which basically has this structure.
{Stats Name="<Product name> (en)" TotalResources="10" ..}
{DayStats Date="2009-12-10" TotalResources="5"}
{DayStats Date="2009-12-11" TotalResources="5"}
{Stats}
{Stats Name="<Product name> (us)" TotalResources="10" ..}
{DayStats Date="2009-12-10" TotalResources="5...