linq

Removing unclosed opening <p>tags from xhtml document

Possible Duplicate: Removing unclosed opening <p>tags from xhtml document I am having big xhtml Document consisting lots of tags. I have observed that few unclosed opening paragraph tags are repeating unnecessarily and i want to remove them or want to replace them with blank space. i just want to code to identifying unclosed...

LINQ and joining on selects

I have the following SQL: select o.tekst as Enhet, coalesce(f.Antall,0) as AntallF, coalesce(f.snitt,0) as SnittF, coalesce(b.antall,0) as AntallB from tblhandlingsplan hp inner join tblorg o on hp.eierorgid = o.orgid left outer join (select f.handlingsplanid, count(t.tiltakid) as Antall, coa...

Use fLinq to persist?

I don't see a lot of examples on how to persist with linq/flinq- I may ultimately write a proc to dowhat I need it to, however the 1->* relationship between tableA and tableC makes that tricky. Can you persist with flinq? Is there a example published somewhere I could follow? Below is what I have tried (or rather the most logical vari...

Setting Up Model Approach in Entity Framework 4

Hello, I am beginning a new project, so one of the tasks given to us is to determine whether we should create one large Entity Framework 4 model (don't know how many tables yet), or split the model into separate models, one per module within the application. If we create separate models, we'll have repeated entities within each module,...

Selecting rows with distinct column values using LINQ

I have a generic list of SharePoint list items (List employees) The SharePoint list contains the two columns, "Employee Name" and "Employee Designation" I want to get an object List which contains distinct "Employee Designation" column values. How do I do this using LINQ? This didnt work for me: var designations = from SPListItem e...

Manipulate Linq output

I've got two queries which I union together in Linq like so; var reWorkData = from a in db.IV30300s join b in db.IV00101s on a.ITEMNMBR equals b.ITEMNMBR into t1 from b1 in t1.DefaultIfEmpty() join c in db.IV30200s on a.DOCTYPE equals c.IVDOCTYP into t2 ...

Implementing a "like" operator multiple times in one Linq to Entities query

We have a list of strings and we need to filter our results by that list. Example would be find all students who have SSNs that start with 465, 496, or 497 (plus x more) List<string> list = GetPossibleStartsWithValues(); var qry = from student in entities.Students.WhereStartsWith(x=>x.SSN, list) select new SearchedStudent { Name ...

C# Listing/Checking Object Variables?

With an ASP.NET MVC project I'm working on, I am required to check whether bit variables within a LINQ-To-SQL class are true. So far, After checking whether or not each variable is true or false, I then push the value of the field into a List and return it like so: public List<String> GetVarList() { List<String> list = new List<Str...

query results can't be enumerated more than once - problem with retrieving data from database

Hi I have a strange problem with retrieving data from database. In my form I have a combobox. The combobox contains couple of items - department's name. Everytime I choose an item from combobox I connect to database and fire this public List<User> SelectAllSecurityUsersByDepartment(string departmentId) { var result = DBConne...

Linq Count, question

I have this simple query -> var games = from p in _oListGames where p.Visitor == team.ID select p I would like to order this select with the COUNT of total games that the p.Visitor has from that list(_oListGames) How would I do that? I would like to order the var "games" by the numbers of visitor games they have currently. ...

Linq to XML, fastest way to find elements?

I have a very simple XML: <Rows> <Row> <id>1</id> <name>foo</name> <more>xyz</more> </Row> <Row> <id>2</id> <name>bar</name> <more>abc</more> </Row> </Rows> and need to do lots of querying on the ID, speed being really key. Would it be more efficient loading the XML into a datatable and creating a PK o...

Query a for a specific object type in a collection

If you have two objects, ObjectA and ObjectB both inheriting from AbstractObject and a collection of AbstractObject. What would a linq statement look like where I select all objects in the collection of specific type. ex. something like: var allBs = from b in collection where type == ObjectB select b; ...

How can I use linq to authenticate username/password?

I'm still learning LINQ. I can do some simple queries, but this one is a little different. I have the following query that authenticates a user. User user = (from u in db.Users where u.Username.Equals(username) && u.Password.Equals(UserSecurity.GetPasswordHash(username, password)) && ...

Does LINQ skip & take have decent performance?

We have a query for about 40 data fields related to customers. The query will often return a large amount of records, say up to 20,000. We only want to use say around the first 500 results. Then, we just want to be able to page through them 10 at a time. Is LINQ skip and take a reasonable approach for this? Are there any potentnialy...

Can I use Expression<Func<T, bool>> and reliably see which properties are referenced in the Func<T, bool>?

I'm writing something in the flavour of Enumerable.Where in that takes a predicate of the form Func<T, bool>. If the underlying T implements INotifyPropertyChanged, I'd like to be a bit more intelligent about re-evaluating the predicate. I'm thinking about changing it to use Expression<Func<T, bool>>, and then using the expression tree ...

Having problems converting conditional where clause in LINQ back over to SQL

Hello all. I've got myself in a bit of a pickle! I've done a snazzy LINQ statement that does the job in my web app, but now I'd like to use this in a stored procedure: var r = (from p in getautocompleteweightsproducts.tblWeights where p.MemberId == memberid && p.LocationId == location...

Create an expression tree in c#

I am attempting to create a dynamic query using expression trees in LINQ to represent the following query WageConstIns.Where(WageConstIn => WageConstIn.Serialno.ToString().StartsWith("2800")); I have attempted to create it like so: MemberExpression le1 = LinqExpression.Property(paramExp, "Serialno"); MethodCallExpression le2 = LinqEx...

Why does LINQ query throw an exception when I attempt to get a count of a type

public readonly IEnumerable<string> PeriodToSelect = new string[] { "MONTH" }; var dataCollection = from p in somedata from h in p.somemoredate where h.Year > (DateTime.Now.Year - 2) where PeriodToSelect.Contains(h.TimePeriod) select new { p.Currency, h.Year.Month, h.Value ...

EF4, Lambda, Repository pattern and DTOs

I have a semi complicated question regarding Entity Framework4, Lambda expressions, and Data Transfer Objects (DTO). So I have a small EF4 project, and following established OO principles, I have a DTO to provide a layer of abstraction between the data consumers (GUI) and the data model. VideoDTO = DTO with getters/setters, used by th...

time portion from datetime value in LINQ

I have field which is of type DateTime. When inserting a record, I am also providing the time into the field. When reading that field with LINQ, it will return me the correct date but the time values has the default, 12:00:00 AM In the database, I have values with date and time for each record which is correct. The problem is that the...