Let's say I have class PersonSummary, which combines properties (columns) from 2 database tables Person and Address (with a foreign key of Person), so a PersonSummary has a First Name, State and Zip.
The creation of PersonSummary could be in a select clause with
(person, address => new PersonSummary {person, address} )
My data access...
Hello All,
Iam using linq to entities and I want to get all Users that haven't signed up for the class. This is what I did.
var classUsers = from cu in myEntities.ClassUsers
where cu.Class.ClassId == classId
select new
{
FirstName =...
I have this class/object below:
public class Person
{
public string FirstName;
public string MI;
public string LastName;
}
Person p=new Person();
p.FirstName = "Jeff";
p.MI = "A";
p.LastName = "Price";
Is there any built in in linq or c# or in subsonic that will create an output of this?:
string myString =...
Hi
I have a basic xml file that looks like this.
<root>
<item>
<title><p>some title</p></title>
</item>
...
</root>
What I want, is to get the whole title string including the html tag of the xml using linq and displaying it in a repeater .
I can get the title with no problem, but the <p> tag is being...
I am using LinQ to XML to populate a dropdown list when my page loads. How can I cache the results so that I don't have to run the query each and every time the page loads? Also the xml file will only be updated once a day. Is it better to cache or just read it each time?
...
I want a Linq Expression which dynamically compiles at runtime
I have a value and if than value greater than say for e.g. 5000 and another value > 70 then it should return a constant x
else
value greater than say 5000 and another value < 70 it returns y
How do I create an expression tree
a > 5000 & b < 70 then d
else
a > 5000 & b >7...
Currently i am using sql encryption and would like to continue using it through Linq. I have all my CRUD stored proc's created and wired up to the table in the model in order to handle the encryption/decryption through sql.
Main problem is that my database model see's a field type of varbinary(max) which is used for the sql encryption ...
I have studied a lot of starter kits for ASP.NET and ASP.NET MVC really is awesome compared to web forms, because it runs fast and developement is easy. But when I fit ASP.NET MVC, LINQ in a site with a lot of visitors and mostly controls based website, I got so many issues in my mind.
Let's say I want to build a website which is small ...
I am learning EF and making some code, and I have this relationship below.
When I try to do:
var users = from u in db.Users
where u.Name.StartsWith("F")
select u;
if(users.Count() > 0)
{
var dto = users.First();
}
The user 'Fabio' is returned, but the area count is 0. He has a relationship with an area...
Does anyone know of a way to do a left outer join with SubSonic 3.0 or another way to approach this problem? What I am trying to accomplish is that I have one table for departments and another table for divisions. A department can have multiple divisions. I need to display a list of departments with the divisions it contains. Getting...
Given the following table:
Length | Width | Color | ID
===========================
18 | 18 | blue | 1
---------------------------
12 | 12 | red | 1
---------------------------
I want to produce a single column/row:
SIZES
=================
18 x 18, 12 x 12,
I can do this in SQL as follows:
DECLARE @SIZES VARCH...
Hello,
I'm currently using Entity framework, and I want to perform a Linq query with a join on two columns, one being of type 'String', and the other of type 'Int32'.
Somethign similar to
from FirstEntity obj in context.FirstEntity
join SecondEntity obj2 in context.SecondEntity on obj.SecondEntityId equals obj2....
I have a LINQ query which searches for a string (using a regex) in multiple fields. I want to sort the results based on in which field the text was found.
Currently I have this:
var results = from i in passwordData.Tables["PasswordValue"].AsEnumerable()
where r.IsMatch(i.Field<String>("Key").Replace(" ","")) ||
r....
private Incident incident = null;
incident = (Incident)(rdc.Incidents.Where(i => i.ID == ID));
I get the following exception:
Unable to cast object of type 'System.Data.Linq.DataQuery`1[WPF.Incident]' to type 'WPF.Incident'.
I need an instance of Incident to use it like this:
IList listInjury = ((IListSource)incident.Incident_Injur...
I have two tables in my database:
Wiki
WikiId
...
WikiUser
WikiUserId (PK)
WikiId
UserId
IsOwner
...
These tables have a one (Wiki) to Many (WikiUser) relationship.
How would I implement the following business rule in my LINQ entity classes:
"A Wiki must have exactly one owner?"
I've tried updating ...
Hi
I would like to convert a list of User's properties into strings array (for json receiver) like:
List<User> users = <..list of users from db...>
var jsonData = (
from user in users
select new { user.Id, user.Person.Lastname, user.Person.Firstname });
return Json(jsonData)
The result is an array named fields
[{"Id":1,"Lastn...
I'm using VB .NET and I know that Union normally works ByRef but in VB, Strings are generally processed as if they were primitive datatypes.
Consequently, here's the problem:
Sub Main()
Dim firstFile, secondFile As String(), resultingFile As New StringBuilder
firstFile = My.Computer.FileSystem.ReadAllText(My.Computer.FileSyste...
Hi guys,
Just learning LINQ and i've come to a newbie roadblock in my test project. Can you explain what i'm doing wrong?
public List<ToDoListInfo> retrieveLists(int UserID)
{
//Integrate userid specification later - need to add listUser table first
IQueryable<ToDoListInfo> lists = from l in db.ToDoLists
...
Hi,
What is difference between these two statements:
var result = from c in context.CustomerEntities
join p in context.ProjectEntities on c.Pk equals p.CustomerPk
where p.Entered > DateTime.Now.AddDays(-15)
select c;
and
var result = from c in context.CustomerEntities
join p in context.ProjectEntities on c.Pk equals p.Customer...
Hi there,
I am trying to insert a standard record into my db using linq2db, but i keep seeing examples to ADD method which i don't appear to have ... what i have currently is the following, as you can see i have my datacontext.... (no add method) ... the Reservation class is a separate class i created as a DTO - i presume this is correc...