Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm using linq to sql. In my program at the beginning, a list is loaded from the SQL database. Then user can add another items. Items are not saved immediately therefore I can not use InsertOnSubmit method in my DB table. I have to save item in the main linq variable and when the user pushes SAVE button it has to be saved.
I tried many ways to add an item in linq variable but none of them worked.

Can anyone help me?

static public void add(UserLoginData item)
{
    try
    {
        item.Order = GetNewOrder();
        UserLoginData[] item_array=new UserLoginData[]{item};
        var usersA = from c in users
                     orderby c.Order
                     select c;
        var usersB = from c in item_array
                     select c;
        var usersC=    usersA.Union(usersB);//related to this error: Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator.
        MainListUsers = from c in usersA
                orderby c.Order
                select c;
        ListRefresh();
    }
    catch (Exception ex)
    {
        Logging.Log.Report(ex.Message, "Error", new System.Diagnostics.StackFrame(true));
    }

}


Christian Graus wrote:
It's a SQL database. Why do you need to use LINQ ?

Therefore what is Linq-to-SQL for?
Posted
Updated 18-Mar-10 19:55pm
v2

1 solution

It's a SQL database. Why do you need to use LINQ ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900