take this linq into consideration:
list.Where(sil => sil.XML.Element("ticket") != null && sil.XML.Element("ticket").Attribute("id").Value == smsRequestIn.TicketID)
if the "ticket" element is not null it searches for it twice and hence is not very effective. Is there a way to use some sort of variables within the linq expression so I c...
I have a User table which has a PrivilegeId foreign key points to a Privilege table and is the primary key there.
In Entity Framework, the VS will not generate a PrivilegeId variable under User for you. It will generate a Privilege property and PrivilegeReference property for you instead.
When I load a User, the Privilege property is n...
I know during the retrieve, I can use Include() to load related Entities (http://stackoverflow.com/questions/2632323/how-to-use-foreign-key-in-l2e-or-ef). but when I want to save or insert data, how to handle those reference Entities?
...
I am creating a WPF app that needs to allow users to work in a temporary disconnected state and I plan to use a Local Database Cache.
My question's are about my data access layer.
Do you typically create the whole DAL
to point at the Cache or both and
create a switching mechanism?
Is Entity's a good way to go for my
DAL against the ...
Let's say I have a struct that contains local environments:
public struct Environments
{
public const string Dev = "DEV";
public const string Qa1 = "SQA";
public const string Prod1 = "PROD";
public const string Prod2 = "PROD_SA";
public const string Uat = "UAT";
}
And I'd like to pull...
I asked on SO a few days ago what was the simplest quickest way to build a wrapper around a recently completed database. I took the advice and used sqlmetal to build linq classes around my database design.
Now I am having two problems. One, I don't know LINQ. And, two, I have been shocked to realize how hard it is to learn. I have...
In c#, Given the following code:
public class Person
{
public int PersonID { get; set; }
public int Age { get; set; }
public string Name { get; set; }
}
and
List<Person> people = new List<Person>();
for (int i = 0; i != 15; i++)
{
Person p = new Person();
p.PersonID = i;
p.Age = i * 12...
I'm just learning XDocument and LINQ queries. Here's some simple XML (which doesn't look formatted exactly right in this forum in my browser, but you get the idea . . .)
<?xml version="1.0" encoding="utf-8"?>
<quiz
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/name XMLFile2.xsd"...
For my ASP.NET MVC 2 application I use Entity Framework 1.0 as my data access layer (repository). But I decided I want to return POCO. For the first time I have encountered a problem when I wanted to get a list of Brands with their optional logos. Here's what I did:
public IQueryable<Model.Products.Brand> GetAll()
{
IQueryab...
Right, bit of a strange question; I have been doing some linq to XML work recently (see my other recent posts here and here).
Basically, I want to be able to create a query that checks whether a textbox is null before it's value is included in the query, like so:
XDocument db = XDocument.Load(xmlPath);
var query = (from vals in db.Desc...
What do you think? How do you map between your domain and presentation model?
...
Can we use Business Objects which we made & data acess Layer of LINQ?
Because i want to put the validation in Business Objects & also want to use data acess Layer of Linq?
...
I am using .Net3.5. Just wondering my understanding about the insert, update, delete are correct when use L2E.
For insert, we need two statements:
context.AddObject("entityName", newRow);
context.SaveChanges();
For update, we only need one statement:
context.SaveChanges();
For delete, we need two statements:
context.DeleteObject...
I have a matrix, IEnumerable<IEnumerable<int>> matrix, for example:
{ {10,23,16,20,2,4}, {22,13,1,33,21,11 }, {7,19,31,12,6,22}, ... }
and another array:
int[] arr={ 10, 23, 16, 20}
I want to filter the matrix on the condition that I group all rows of the matrix which contain the same number of elements from arr.
That is to say t...
I am using ASPNET membership with 50000 records, and we have another table called "scm_Users" which has exactly number of records, they are NOT linked by any key. I have a simple SQL:
select * from dbo.aspnet_Users a, dbo.scm_Users b
where a.UserName = b.UserName
I can get 50000 records in less than 1 second.
In LINQ, (using Entity F...
Say I take an arbitrary LINQ2SQL query's Expression, is it possible to invoke it somehow?
MyContext ctx1 = new MyContext("...");
var q = from t in ctx1.table1 where t.id = 1 select t;
Expression qe = q.Expression;
var res = Expression.Invoke(qe);
This throws ArgumentException "Expression of type System.Linq.IQueryable`1[...]' cannot ...
I am trying to convert the following SQL into a LINQ expression
SELECT COUNT(ID) AS Count, MyCode
FROM dbo.Archive
WHERE DateSent>=@DateStartMonth AND DateSent<=@DateEndMonth
GROUP BY MyCode
and I have been trying to follow this webpage as an example:
http://stackoverflow.com/questions/606124/converting-sql-containing-top...
I have 2 tables (Users and Roles) they are mapped as Many-to-Many in relational db. When I imported to Entity Data Content, they are still staying as the same relationship.
Since they are mapped as Many-To-Many in Entity, I can access
Users.RoleCollection
or
Roles.UserCollection
However, when I execute this LINQ query, I got "LINQ...
Using the following code:
Private Sub MakeMeSomeXmlBeforeRyanGetsAngry()
Dim db As New MyDBDataContext
Dim customer = From c In db.Customers Select c
Dim dcs As New DataContractSerializer(GetType(Customer))
Dim sb As StringBuilder = New StringBuilder
Dim writer As XmlWriter = XmlWriter.Create(sb)
dcs.Writ...
Hi,
I'm having trouble correctly binding a listbox to an XML datasource (text .xml file).
I'm learning how to use WPF and LINQ to XML by following the Microsoft example with the books list, which binds to an inline XML source, shown here...
http://msdn.microsoft.com/en-us/library/bb669149.aspx
What I am trying to do is change this a...