Skip to content

LINQ

LINQ (all flavours)

This category can be followed from the open social web via the handle linq-e04cf296@forum.codeproject.com

783 Topics 2.8k Posts
  • 0 Votes
    8 Posts
    21 Views
    B
    Hi Guys, i had the same issue after reading your post i figured it out! Thanks. I thought i would pop some code on it for all to see :-\ hope it helps someone like u guys helped me public partial class _Default : Page { protected void Page_Load(object sender, EventArgs e) { AddUser(); BindData(); } public UserClass AddUser() { DataClasses1DataContext db = new DataClasses1DataContext(); //Where User is the Class Generated by LINQ that is mapped to my DB Table LinqMapping.User user = new User(); user.Name = "Butch"; user.Surname = "Zn"; user.Active = true; db.Users.InsertOnSubmit(user); db.SubmitChanges(); return null; } public ICollection<UserClass> GetUsers() { DataClasses1DataContext db = new DataClasses1DataContext(); var userList = from u in db.Users select u; ICollection<UserClass> list = new List<UserClass>(); foreach (var user in userList) { list.Add(new UserClass {Id = user.id, FirstName = user.Name, Surname = user.Surname, Active = user.Active}); } return list; } public void BindData() { ICollection<UserClass> user = GetUsers(); GridView1.DataSource = user; GridView1.DataBind(); }
  • Problem Importing BO From File

    database sql-server sysadmin xml help
    3
    0 Votes
    3 Posts
    9 Views
    B
    I'm looking to improve the whole scenario where the BO imported from file actually already exists in the DB. My blog is acceptably unique.
  • 0 Votes
    5 Posts
    16 Views
    J
    Hi, The filter and sorting functionality is based upon the defaultview of the DataTable or the DataSet. You may try converting System.Data.Linq.Table to a DataView or a DataTable. And then bind the grid to the resulting DataView/DataTable. To achieve this, you may refer the code provided at: http://blogs.msdn.com/aconrad/archive/2008/01/11/pathetic-plea-for-help.aspx Hope this helps. Vinay ComponentOne LLC. www.componentone.com
  • Object adding itself ...

    question announcement
    13
    0 Votes
    13 Posts
    32 Views
    P
    Right, I've got Jammer's, Navaneeth's and your email addresses now. When I'm finished I'll send it on to you. Deja View - the feeling that you've seen this post before. My blog | My articles
  • asp.net 3.5 and ajax

    help csharp javascript asp-net sysadmin
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Very frustrating LINQ question

    csharp database dotnet winforms linq
    5
    0 Votes
    5 Posts
    11 Views
    P
    Finally found what the problem was. Instead of using the DB in the project's folder, Visual Studio copies the database to the debug folder each time it compiles the project, so I didn't see an change, because the changes were saved to the wrong DB... So I can go on now
  • 0 Votes
    3 Posts
    7 Views
    J
    Thanks chap, I've moved it to the C# forum. Jammer Going where everyone here has gone before! :) My Blog
  • Good Practices: DataContexts and BO's

    csharp css database winforms linq
    2
    0 Votes
    2 Posts
    8 Views
    J
    Brady, the way you're doing it sounds reasonable. Another approach may be to modify your BO to support a transaction: when your details form opens up, call BO.BeginTransaction. When the user clicks save, commit the transaction. If not, rollback the transaction. I'm sure there are a number of ways to do this. I don't know whether a transaction approach is superior to your BO copy approach. Life, family, faith: Give me a visit. From my latest post: "A lot of Christians struggle, perhaps at a subconscious level, about the phrase "God of Israel". After all, Israel's God is the God of Judaism, is He not? And the God of Christianity is not the God of Judaism, right?" Judah Himango
  • 0 Votes
    3 Posts
    9 Views
    M
    Thanks for your reply
  • SQL to LINQ Converter

    csharp database linq question
    14
    0 Votes
    14 Posts
    31 Views
    U
    SQL to LINQ converter is available at www.sqltolinq.com
  • Error in Query?

    database com help question
    2
    0 Votes
    2 Posts
    8 Views
    P
    var sStock = from S in QryGen.T_Stocks join R in QryGen.T_RG_Masters on S.F_RGMaster_ID equals R.F_RGMaster_Id where ( ( S.F_Thick > dEnThick && (S.F_Width >= dMinWidth && S.F_Width <= dMinWidth) && (S.F_Length >= dMinLength && S.F_Length <= dMaxLength) ) || ( S.F_Length > dEnLength && (S.F_Thick >= dMinThick && S.F_Thick <= dMaxThick) && (S.F_Width >= dMinWidth && S.F_Width <= dMaxWidth) } ) && S.F_GradeMaster_Id == iGradeMasterId && S.F_STATUS == true && S.F_CMP_ID == globalvar.g_iCmpId select new { S.f_stock_id, S.F_BAR_NUMBER, S.F_Thick, S.F_Width, S.F_Length, S.F_Lot_Number, R.F_RG_PageNo, S.F_RESERVE_STATUS, S.F_STOCK_DATE }; The line in bold looks wrong. I assume what you really meant to put here was: && (S.F_Width >= dMinWidth && S.F_Width <= dMaxWidth) Deja View - the feeling that you've seen this post before. My blog | My articles
  • Entity - problems retrieving database model

    help database security tutorial
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Basic Schema Validation Missing

    database csharp linq xml question
    8
    0 Votes
    8 Posts
    20 Views
    P
    Brady Kelly wrote: Have you done any work with the Entity Framework? A little bit. We aren't going to commit to doing anything serious with it until we've had a chance to evaluate the final version. I'm sick of having to change things because MS decides to revamp things between releases. Deja View - the feeling that you've seen this post before. My blog | My articles
  • DataGridView and SubmitChanges

    question
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Noob Type Question

    csharp linq help question lounge
    6
    0 Votes
    6 Posts
    13 Views
    P
    To convert it into an anonymous list, try: productsdump.ToList(); Deja View - the feeling that you've seen this post before. My blog | My articles
  • Create Custom .dbml file

    help
    4
    0 Votes
    4 Posts
    8 Views
    J
    reza toorani wrote: I want design data access layer for the medium application,I want use linq to sql for it. Ok, that works. reza toorani wrote: I need which genarate code for entities of application. The Visual Studio designer will generate classes for objects stored in your tables, if that's what you mean. If you don't have Visual Studio, the SqlMetal[^] tool inside the .NET framework will do it. reza toorani wrote: for that i want inherite the class of a datacontext from my class. Again, this is not possible. I do not understand why you need to do this. reza toorani wrote: User interface is important for that. User interface for your application? Or for generating the entities?
  • Linq Question [modified]

    question csharp linq data-structures
    3
    0 Votes
    3 Posts
    9 Views
    T
    Thanks Judah, That seems to be the way to go Don't be overcome by evil, but overcome evil with good
  • Multiple Join Query

    csharp database question visual-studio linq
    2
    0 Votes
    2 Posts
    6 Views
    C
    DOH!!! :-O :-O :-O :-O var bids = from bp in dc.BID_PROJECTs join company in dc.COMPANies on bp.Company_URN equals company.URN join pm in dc.EMPLOYEEs on bp.Management_Team_URN equals pm.URN select new { bp.BP_BPR, bp.BP_Title, bp.BP_Status, bp.BP_Type, CompanyName = company.Name, PMName = pm.Name }; Jason Brown C# Developer
  • Merging and concatenating similiar records with linq to xml

    csharp linq com xml help
    2
    0 Votes
    2 Posts
    8 Views
    J
    Ok, I'm not a Linq to XML expert, but here's my little attempt to get your "List Type 1; List Type 2; List Type 3" string: XDocument doc = XDocument.Load("Source.xml"); var listDescriptions = from node in doc.DescendantNodes()                       let element = node as XElement                       where element != null && element.Name == "ListDescription"                       select element.Value; var concatenatedListDescriptions = listDescriptions.Aggregate((in1, in2) => in1 + ";" + in2); After that, you've got your concatenated ListDescription. All that's left is writing the final document with this concatenated string in there. FWIW, I used this Linq to XML article[^] to figure out some stuff. Also, the Aggregate call that actually concats the strings together not optimal - ideally you'd have a StringBuilder that pieces them together. Life, family, faith: Give me a visit. From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord." Judah Himango
  • 0 Votes
    2 Posts
    7 Views
    J
    Regarding binding to the content of the document, did you see the Bindable LINQ post right below this? I'm not sure if that works given your inability to "specify the structure of the enumerable". (Not quite sure what you mean by that, though, maybe you can clarify.) Life, family, faith: Give me a visit. From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord." Judah Himango