linq to sql generates members as non-public
I have 2 tables related by a foreign key. The problem is the children of one the father-entity are created as non public members and i cant reach them in code. ...
I have 2 tables related by a foreign key. The problem is the children of one the father-entity are created as non public members and i cant reach them in code. ...
I'm trying to write a linq-to-sql query using || that behaves the same way as the OR in SQL when combined with a LIKE/Contains. SQL: SELECT * FROM Users WHERE GroupNumber = 'A123456' OR (FirstName like 'Bob%' AND LastName like 'Smith%') This will result in everyone with a name like "Bob Smith" as well as everyone with a GroupNumber e...
Is there a way to configure the way linq-to-sql generates the property names in a stored precedure result. I want them all upper case independent from the upper and lower case that were used in the stored procedures. ...
Is it possible to create a new table programatically in EF or L2S and load it to its context? We have this application that requires to create a table at runtime and do some CRUD activities to that table. Is this possible? If not, any advice? ...
I'd like to know how to get a subset of data from a table using Linq To SQl Lambda expressions... Let's say I have a table tbl_Product, with fields ProductId, ProductCode, ProductName, Description, WhyBuyCopy, how do I get only the first three fields when the others are not needed given that retrieving all data takes a second longer (ch...
How to expand this query: public Dictionary<int, List<TasksInDeal>> FindAllCreatedTasks() { return (from taskInDeal in db.TasksInDeals where taskInDeal.Date > DateTime.Now && taskInDeal.Date < DateTime.Now.AddDays(7) group taskInDeal by taskInDeal.CreatedByUserID into groupedDemoClasses ...
Why is the following adding an Insert (of the new Address) to the DataContent ChangeSet, and how can I stop it from doing so? var db = new DataClasses1DataContext(); var a = new Address(); a.StateProvince = db.StateProvinces.First(); Console.WriteLine(db.GetChangeSet().Inserts.Count); ...
In our project we are invalidating the cache based on the change in the query output. This is implemented using change notifications. In the Global.asax file in the Application Start block we have also added SqlDependency.Start(ConnectionStr). But still its throwing the following invalid operation exception Message "When using SqlDepend...
What is the easiest way to rebuild a dbml file with Visual Studio 2008? There is no "refresh" option in popup menu as in the Entity Framework wizard. I use bat file (that executes sqlmetal) from the project nowadays. ...
Hi, can anyone tell me why this doesnt work? public class GeocodeCoord { public string Outcode { get; set; } public int X { get; set; } public int Y { get; set; } } List<GeocodeCoord> _geocode; using (MyDataContext db = new MyDataContext()) { _geocode = db.Geocodes.Select(g => new GeocodeCoord { g.postcode, g.x...
I have a following classes class User { [Column]public int Id; [Column]public string Name; [Column]public Company Company; } class Company { [Column]public int Id; [Column]public string Name; [Column]public Address Address; } class Address { [Column]public int Id; [Column]public string Street; [Col...
Working with interfaces, we commonly have a var or an IQueryable that is going to return a set of data objects that we will then cast to the interface and return as a List or IList, like this: var items = from t in SomeTable where t.condition == true select; return items.ToList( ).Cast<SomeInterface>( ).ToList( ); NOTE: items.Cast...
I was checking 2nd edition of Professional ASP.NET MVC and realized EF replaced LINQ to SQL. I am familiar to LINQ to SQL from the first book but I know nothing about EF. Anyway while reading the code, it seems like nothing has changed except the name. Same old repository, same old functions. I did a little research. I know LINQ is not...
I would like to execute a Linq to Sql statement that captures the count and average in a (filtered) set of data. What I have works, but it requires two queries to the database when it should be possible in one query. Interestingly enough, I can get one query to be emitted when I use a group by clause. For example: select count(*), avg...
Is it safe to call SubmitChanges() when you are not sure whether the data has changed? What does it actually do? ...
Hi All, We tried using the below code snippet but showing the syntax error. var query = (from def in entity.Defect.Where("Owner == @0", "rochs") select def).ToList(); Thanks in Advance ...
Hi All, Are there any implications of using SqlDependency and LINQ to SQL together. Or do we have to take care of some things specially to make them work properly? In our application we are using LINQ to SQL as an ORM and business logic is in the Stored Procedures. We cache the output of the SPs and create SQLDependency. Whenever the o...
I suppose the question was asked before (it's so general) but I can't find the answer. How can I retrieve auto generated integer primary key value after I inserted a new row and called "SubmitChanges" ? I need to know the key exactly on the client-side 'cos I'm going to use this value further for calculations. When unique key is Gui...
On my ASP.NET MVC application I'm running a couple of inserts at once that can insert 10000 or more lines and update a few others. This process is taking a long time but I can't escape the insert because that's exactly what I was asked to do. Right now I'm running Sql Server Profiler and it takes almost 20 minutes to insert this bunch of...
this is data id code status 1 1 5 2 1 6 3 2 8 4 2 9 5 2 12 6 3 15 7 3 19 8 3 13 what I need as a result is this: id code status 2 1 6 5 2 ...