How can I databind ASP.Net Menu Control using LINQ to SQL
I'm new to LINQ and I have an ASP.Net Menu control, I want that to be generated dynamically using LINQ complete with Parent and Child nodes. Hope someoene could help. ...
I'm new to LINQ and I have an ASP.Net Menu control, I want that to be generated dynamically using LINQ complete with Parent and Child nodes. Hope someoene could help. ...
Take a look at my code here: public static ItemType GetItem(int id) { ItemType it = new ItemType(); using (var context = matrix2.matrix2core.DataAccess.Connection.GetContext()) { var q = (from ci in context.Item where ci.ID == id let TemplateID = ci.Templa...
I want to implement this function: Public Function GetFunc(Of TSource, TResult) _ selector As Expression(Of Func(Of TSource, TResult)) _ As Func(Of TSource, TResult) 'Implement here End Function UPDATE I have the following issue, it's a part of a function: Dim obj As Object = value For Each exp In expressions If ob...
I have a generic object with properties: Class MyObject { public Dictionary<string, Object> properties = new Dictionary<string, Object>(); public object this[string name] { get { return properties[name]: null; } } List<MyObject> People= new List<MyObject>(); People.Add(new MyObject(age = 50, home = "Dublin", name = "Bob", Income...
I'm trying to write a dynamic linq query like: var q = obj.Where("message.Contains('hello')"); I know it works for var q = obj.Where(o => o.message.Contains('hello')); but i'm looking for dynamic linq solution Thanks. ...
How can I create an easy helper method to get an int array from a collection of objects? The idea would be have a method which receive a collection of "User" class: public class User { public int UserId {get;set;} public string UserName {get;set;} } And filter this collection to get an int array of unique UserIds. List<int...
Here's my code var bt = new BachtuocvnDataContext(); var matchedTeams = (from lt in bt.Bet_Leagues_Teams where lt.LeagueID == leagueID select (lt)).Single(); matchedTeams.TeamID = teamID; bt.SubmitChanges(ConflictMode.ContinueOnConflict); It does not upd...
I have a query that needs to be reused all over the place and I need to vary which property/column gets used for a join. What I'd like to be able to do is something like: query = RestrictByProp(query, x=>x.ID); An extremely simplified RestrictByProp() could be*: private static IQueryable<Role> RestrictByProp(IQueryable<Role> query,...
Hi, I'm iterating over an anonymous type with about 1000 elements. The question here is how is it possible that my loop takes almost 3 seconds to complete while what inside the loops happens takes less than 1 ms. With a thousand elements i figure the loop must finish within the second, not 3. Is there a way to make it iterate faster? ...
I have the 2 collections: IEnumerable<Element> allElements List<ElementId> someElements, What is a concise way of doing the following together: [1] Verifying that all elements in someElements exist in allElements, return quickly when condition fails. and [2] Obtain a list of Element objects that List<ElementId> someElements maps t...
Is there an easy way to delete all child records for an item using Linq to sql? ...
I have a repository accessing my Entity Framework. I have a method that looks like this: public TEntity FindOne(Expression<Func<TEntity, bool>> criteria) { var query = _queryAll.Where(criteria); return query.FirstOrDefault(); } I have 2 Entities that have a one to many relation. Lets call them Courses and Students. A Course c...
I have the following T-SQL that replaces blank values with '[Unknown]'. How can I achieve this in a LINQ to EF query? select distinct case when CostCentre = '' then '[Unknown]' else CostCentre end as CostCentre ...
I'll say up front that I am doing some really scary things with linq on dynamic data. But I can't figure out why this query fails to compile: Error 1 The property '<>h__TransparentIdentifier0' cannot be used with type arguments public class Program { public static void Main(string[] args) { var docs = new dynamic[0...
Lets say i have a form which have the following : Name:TextBox Email:TextBox Age:TextBox now i want to Get customers Collection based on this filter textboxs so i want to to use something like : List<customer> customers = getCustomerswhere(c=>c.name == txtName.Text && Email == txtEmail.Text); now of course i dont know which...
Hi all, My problem requires 3 (not too long functions) to reproduce (VS2010 / .NET 4) In the first case, my IEnumerable is not evaluated (through the ToList() method) I can't see why.. // Main program private void ButtonTest_Click(object sender, RoutedEventArgs args) { int[] indexes = new int[] { 2, 2, 2, 2, 2, 2 }; v...
Lets say i have : Func<Customer,bool > a = (c) => c.fullName == "John"; now i want to convert to expressiontree any way to do that ? i know i can define it from the first place as expressiontree but the situation i have is different because i must concatenate some lambda expressions first then pass it to a method which take express...
LinQ contains the method Cast which casts each entry in the list to type T. Lets say we have a list which looks like the following: List<Object> obj = new List<Object>(); obj.Add("A"); obj.Add("B"); A working cast could be var list = obj.Cast<string>(); What I would like to work Type t = typeof(String); Object list = obj.Cast(t); ...
I have a method right now that loops through a list of business objects name Properties has a Serial # or not. If I find a Serial #, I exit the loop and return true, otherwise I return false. Code is as follows: public bool HasSerialNumber() { if (this.Properties != null && this.Properties.Count > 0) { ...
Hello, I wrote this LINQ code: from workTask in VwWorkTask.Where(e => e.TaskStateStr != "A" && e.TaskStateStr != "B") join workContext in TblWorkTOBProlongationWorkContexts on workTask.WorkContextId equals workContext.Id join client in VwClient on workContext.Client equals client....