Here's the code:
string name = "myName";
int id = (int)_myDB.ThingTable.Where(thing => thing.ThingName == name)
.Select(thing => thing.ThingId);
I have an error saying System.Linq.IQueryable cannot be converted to int (I'm assuming it's so that I don't end up with a case where no rows are found- no id is returned...
Hi,
I've built a repository and I want to run a bunch of tests on it to see what the functions return.
I'm using Visual Studio 2008 and I was wondering if there's any sandbox I can play around in (Whether in visual studio 2008 or not) or if I actually have to build a mock controller and view to test the repository?
Thanks,
Matt
...
Hi,
Entity framework is cripplingly slow so i tried using a stored procedure but i ran into this problem..
Entity Framework allows you to define a stored procedure that produces an entity. However my entity has 'navigation properties' which are not being populated when using this method.
Is there a work around?
Thanks
...
Hi,
How do I serialize entity framework object into JavaScript Object (JSON)? I tried using JSON.NET but I am getting the following exception when I try to serialize it.
Exception: Newtonsoft.Json.JsonSerializationException, Message="Self referencing loop"
Hitesh
...
I know currently the compiler is not liking this statement. Getting Error
Cannot convert lambda expression to delegate type 'System.Func<MyData.Models.SomeModels,bool>' because some of the return types in the block are not implicitly convertible to the delegate return type
My Statement I'm passing to my Repository Class
var qry = rep...
I'm programmatically creating an edmx file as part of our code generation process and I'd like to know how the designer decides to use "1" or "0..1" for a relationship when you "Update model from database". Any insight on this? Thanks
Edit:
Ok, I think it uses "0..1" when the "many" side is a nullable foreign key and "1" if it's not nu...
I was trying to use ajax to retrieve data from a repository using a controller and I kept getting Internal Server Errors... I've whittled it down to the line:
private MyDBEntities _myDB = new MyDBEntities();
That's located in the repository, without that line I don't get the Internal Server Error.
The line is called after the Reposito...
Is it possible to query the context, make a change to an entity, and then re-query the context and get a result set back that includes the changed entity without doing a savechanges? (I don't want to savechanges because I may want to rollback)
I know I can get the changes back by using GetObjectStateEntries, but I'm interested in the e...
I am wondering how the shift from relational, table-based design to object-oriented, entity-based design is affecting the mindset of developers writing the next wave of applications.
Given the nature of the debate swirling around the Entity Framework and Linq to SQL, is it premature to be thinking about entity-driven design?
Are we bri...
Hi,
My entity framework provider (CoreLabs/Mysql/devart) is creating ridiculously slow queries.
is it possible for me to set the actual sql query that will be executed?
Thanks
...
Possible Duplicate:
How to get current user in Asp.Net MVC
I've tried a bunch of different things, I know I've done it before when I used Webforms, but I can't seem to figure out how to do it in MVC.
Membership doesn't work
User gives me an IPrincipal or something User.Identity gives me the same type of variable...
Anyone know...
Every sample I come across has the entities and properties in the storage model named exactly the same as in the conceptual model. So in the mapping section, I can't tell whether an entity or property is from the storage model or conceptual model.
This is a snippet of an Entity Framework diagram. Which "ID" fields are from the database ...
I am trying to figure out the best way to bind to an unrelated table in .Net. I have an ADO .Net Entity data model which contains several related tables and a few unrelated tables.
For example, I have the following tables:
KEY_VALUE_LKP with columns LKP_TEXT, LKP_VALUE and LKP_TYPE
REQUEST_DET with columns REQUESTNO, USERID, and REQ_S...
I’m having trouble updating an objects child when the object has a reference to a nonexising child record.
eg.
Tables Car and CarColor have a relationship. Car.CarColorId >> CarColor.CarColorId
If I load the car with its color record like so this
var result = from x in database.Car.Include("CarColor")
where x.CarId = 5
...
Hi,
Simple question - what does this actually do?
var oq = (ObjectQuery<TEntity>)L2EQuery;
return ExecuteFirstorDefault<TEntity>(oq, MergeOption.AppendOnly);
It's partly from the book Programming Entity Framework, by Julia Lerman.
...
Hello,
In Entity Framework, using LINQ to Entities, database paging is usually done in following manner:
int totalRecords = EntityContext.Context.UserSet.Count;
var list = EntityContext.Context.UserSet
.Skip(startingRecordNumber)
.Take(pageSize)
.ToList();
This results in TWO database calls.
Plea...
It looks like GetObjectKey has the benefit of searching for existing, instantiated objects, and THEN the data store. However, it also seems like you lose some of the strong typing, and need to cast your resulting object:
GetObjectKey
int customerID = 1;
EntityKey key = new EntityKey("MyEntities.Customers", "CustomerID", customerID);
C...
When I create a new diagram and "Update model from database", the StoreGeneratedPattern attribute gets added to some primary key properties, but not all of them. What criteria does the designer use to decide whether to add this or not?
...
Is there any way to add custom attributes to properties in EF generated code? The only thing I can see as a plausible solution would be to come up with a custom T4 template. However, because of the nature of the attribute it would be impossible to determine the correct attribute parameter per EF property.
...
I am trying to use the stored procedure mapping feature in Entity Framework to perform the insert update and delete functions.
For whatever reason the procedures are not being called. They are correctly mapped, and supposedly all I have to do is call SaveChanges(); in my controller for them to execute.
Using this tutorial as a referenc...