In an approval workflow I want to ensure that reminder emails are sent exactly once.
With SqlCommand.ExecuteNonQuery I can ensure this by testing the return value.
What is the recommended solution using EF?
According to the documentation ObjectContext.SaveChanges does not return an equivalent value.
SqlCommand example:
(The Transaction...
I have a class Address Generated by entity Framework.
I Have an propertie AddressID in this class.
I Would like to be able to add some treatement for this prop in the set process.
EX :
public partial class Address
{
public bool _AddressID;
public bool AddressID{get return AddressID;}
set{
if(value =...
I'm a bit confused about when using the "IRepository pattern", when actually to load the data.
Currently I have something like this:
public class MainViewModel : ViewModelBase
{
// EF4 generated ObjectContext
private ScorBotEntities context = new ScorBotEntities();
// Custom IUserRepository class
private IUse...
I have been adding partial classes of my different entities to add various useful methods without issue.
Attempting to add properties appears to be straightforward based on examples that I've seen, but mine are failing miserably.
Updated example:
public List<Friend> FriendsInGoodStanding
{
get
{
...
1 - Is it necessary to have foreign key to obtain a Relation in Entity Framework between each entity.?
2 - I have a Language Table and many many table with a foreign key related to the language table. Is it right to add this foreign key or I should do something else ?
Ex:
Language
LangID
LangName
TableTextA
TblAID
TextInfo
Lan...
For a new project I'm trying to create my business classes first and create the real database tables later. Therefore I'm using the Entity Framework 4 Designer. A created a new "ADO.Net Entity Data model" file, with the extension .edmx.
I created two Entities:
I want to add a 1 to nc relation between Product -> Group. If I'd created t...
Can anyone reliably get the EntityDataSource to save a nullable column to the databse as a "null" when bound to any of the controls, such as "FormView"?
I have tried using several different UpdateParameters (SessionParameter, ControlParamater, Parameter, etc). I have tried setting "ConvertEmptyStringToNull" to true and leaving the prop...
i started an ASP.net web project app to learn how EF4 can be used. In my project i have defined 3 layers(DAL => Entity Framework 4, BLL => Business Logic Layer, UI).
The BLL and DAL share POCOs generated using the template feature of EF4.
For example i have "User" Poco class that looks like this:
public partial class User
{
#regio...
Hello,
I have a SQLCe database which had a unique primary key Id with type uniqueidentifier, and child relationship, 1 to many, where i keep the master id in a column and append unique id for every row too. Now I use POCO entities for my domain model NOT STE. While adding and modifying entities works OK, I have hard time to delete, say ...
From another thread that gave me the information on how to add monitoring to an SQL Server...
http://stackoverflow.com/questions/3586736/see-sql-from-entityframework-with-collection-like-queries
This works well, but I want to take it a step further. I'd like to be able to add comments into the log when Transactions are happening.
I w...
I have a code-first, POCO project in which I am trying to adjust an existing database so that it syncs up with what EF is expecting, given my existing model.
I have these entities:
public class FlaggedDate
{
[Key]
public long scheduledDayID { get; set; }
[Required]
public DateTime date { get; set; }
[StringLength(50...
I’m researching EF4 for a new in-house application development project using .NET v4, EF4, & SQL Server 2008 R2. To date, our small dev team has done very little .NET development and only demonstration EF applications. Our current applications use DB app-roles for security and that's worked out well for us.
From reading and some basic ...
Hi,
I'm currently in a situation where I need to delete entities without having access to the associated ObjectContext. I read about identifying relationships and they seem to be exactly what I need: I want to delete an object, once it is no longer referenced by its "parent" object.
I am using Visual Studio 2010 Premium to generate my ...
Hi folks,
I've got the following entities on my EDMX :-
These two entites were generated by Update Model From Database.
Now, notice how my country has the following primary key :-
Name & IsoCode
this is because each country is UNIQUE in the system by Name and IsoCode.
Now, with my States ... it's similar. Primary Key is :-
Name ...
I have a simple database with 2 main tables with a many to many relationship through a 3rd bridge/join table.
This 3rd table has an extra field besides the two keys required, so that Entity Framework transforms it into a full entity rather than a many to many relationship between the other 2 tables.
I cannot change this third table i...
Is it possible to call a custom method in a lambda expression.?
//Address a : It's an Entity
public string AddressConstructor(Address a)
{
return a.City + "," + a.Province;
}
var Test = _db.MyTableTest.Select( t => new ViewModel
{
MyID = t.ID,
...
I want to load an entity and it's children conditionally (I only want to eager load the children when the child.IsActive == true). How do I perform the following?
var parent =
from p in db.tblParents.Include("tblChildren") <-- where tblChildren.IsActive == true
where p.PrimaryKey == 1
select p;
NOTE: I do not want to retu...
I am new to both MVC as well as Entity Framework, but I want to do my next project using those technologies. I went through the NerdDinner tutorial at http://nerddinnerbook.s3.amazonaws.com/Part1.htm. NerdDinner uses Linq to Sql and uses the Repository pattern to manage data access. NerdDinner is written so well that I wanted to use it...
I know there are a lot of threads here already on the repository pattern but somehow I feel my question is a little different. May be because yesterday was the first time I heard of the word POCO.
My question is this--usually, I have add and save methods in my business entities. Say I am writing a Q/A site, and I have the following e...
When I try to use these two features together, I get a compilation error on my model (note, I've renamed the entity for my _CT table "ContentHistory" and my SL4 Unit Test project is called "DomainServices.UnitTest":
Error 39 Property 'DomainServices.Web.ContentHistory.C___seqval' is marked as a key
property and is of Type 'System.Byte[]...