Search Results

Search found 899 results on 36 pages for 'ef 5 0'.

Page 5/36 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • EF + UnitOfWork + SharePoint RunWithElevatedPrivileges

    - by Lorenzo
    In our SharePoint application we have used the UnitOfWork + Repository patterns together with Entity Framework. To avoid the usage of the passthrough authentication we have developed a piece of code that impersonate a single user before creating the ObjectContext instance in a similar way that is described in "Impersonating user with Entity Framework" on this site. The only difference between our code and the referred question is that, to do the impersonation, we are using RunWithElevatedPrivileges to impersonate the Application Pool identity as in the following sample. SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(url)) { _context = new MyDataContext(ConfigSingleton.GetInstance().ConnectionString); } }); We have done this way because we expected that creating the ObjectContext after impersonation and, due to the fact that Repositories are receiving the impersonated ObjectContext would solve our requirement. Unfortunately it's not so easy. In fact we experienced that, even if the ObjectContext is created before and under impersonation circumstances, the real connection is made just before executing the query, and so does not use impersonation, which break our requirement. I have checked the ObjectContext class to see if there was any event through which we can inject the impersonation but unfortunately found nothing. Any help?

    Read the article

  • Different EF Property DataType than Storage Layer Possible?

    - by dj_kyron
    Hi, I am putting together a WCF Data Service for PatientEntities using Entity Framework. My solution needs to address these requirements: Property DateOfBirth of entity Patient is stored in SQL Server as string. It would be ideal if the entity class did not also use the "string" type but rather a DateTime type. (I would expect this to be possible since we're abstracting away from the storage layer). Where could a conversion mechanism be put in place that would convert to and from DateTime/string so that the entity and SQL Server are in sync?. I cannot change the storage layer's structure, so I have to work around it. WCF Data Services (Read-only, so no need for saving changes) need to be used since clients will be able to use LINQ expressions to consume the service. They can generate results based on any given query scenario they need and not be constrained by a single method such as GetPatient(int ID). I've tried to use DTOs, but run into problem of mapping the ObjectContext to a DTO, I don't think that is theoretically possible...or too complicated if it is. I've tried to use Self Tracking Entities but they require the metadata from the .edmx file if I'm correct, and this isn't allowing a different property data type. I also want to add customizations to my Entity getter methods so that a property "MRN" of type "string" needs to have .Replace("MR~", string.Empty) performed before it is returned. I can add this to the getter methods but the problem with that is Entity Framework will overwrite that next time it refreshes the entity classes. Is there a permanent place I can put these? Should I use POCO instead? How would that work with WCF Data Services? Where would the service grab the metadata?

    Read the article

  • Multilingual best practices on SQL Server, EF and MVC combinations

    - by dengereli
    ASP.NET MVC, resource management is look like enough for application multlingual multiculture support. But I am wondering practices about data. User stories; User set culture as en-US and see all product items in English. User set culture as fr-FR and see all product items in French. User set culture as ru-RU and see all product items in Russian. User doesn't have right change culture settings and application never reach multilingual resources, it will use default language and culture.

    Read the article

  • EF exception: Could not find file CodeGenerationSchema.xsd

    - by DK
    I'm using Entity Framework for a new project (VS 2008, .net 3.5 sp1) and "reasonably happy" with it, especially compared to dataset-based solutions. One of recurring annoyances is "Could not find file CodeGenerationSchema.xsd" exception during application startup. Exception seems to re-appear rather frequently after changes to the model. Googling gives temporary and strange workarounds for this error: Delete .suo file, or Set Options Debugging General Enable Just My Code = On May be someone have more permanent, straightforward fix or can explain the reason of this issue.

    Read the article

  • How to add additional data column in EF using ASP.Net MVC 2

    - by Picflight
    My Table: [LocationId] [Address] [ZipCode] When I show a list of Location's, I also want to show the distance from a given zip code. In Asp.Net Web Forms I had a stored procedure that would return the distance and I would call this SP on ItemDataBound on my GridView. Or, I also would have my SP that is returning the Location list add another column ([Distance]) which I could display in my GridView. How would you do this using Entity Framework and Asp.Net Mvc 2?

    Read the article

  • Membership with Mysql, EF 1 and ASP.NET 3.5

    - by sanfra1983
    Hi, I created a web application with asp.net 3.5 and ado.net entity framework WebForms 1, but have not yet succeeded in creating a memebrship and roles. When I go on ASP.NET Configuration and click the Security Tab I get the following error: Keyword not supported. Parameter name: metadata Someone has already created an application with these same features to help me understand where is the problem? P.S.: I'm going crazy Thanks to all

    Read the article

  • EF Many-to-many dbset.Include in DAL on GenericRepository

    - by Bryant
    I can't get the QueryObjectGraph to add INCLUDE child tables if my life depended on it...what am I missing? Stuck for third day on something that should be simple :-/ DAL: public abstract class RepositoryBase<T> where T : class { private MyLPL2Context dataContext; private readonly IDbSet<T> dbset; protected RepositoryBase(IDatabaseFactory databaseFactory) { DatabaseFactory = databaseFactory; dbset = DataContext.Set<T>(); DataContext.Configuration.LazyLoadingEnabled = true; } protected IDatabaseFactory DatabaseFactory { get; private set; } protected MyLPL2Context DataContext { get { return dataContext ?? (dataContext = DatabaseFactory.Get()); } } public IQueryable<T> QueryObjectGraph(Expression<Func<T, bool>> filter, params string[] children) { foreach (var child in children) { dbset.Include(child); } return dbset.Where(filter); } ... DAL repositories public interface IBreed_TranslatedSqlRepository : ISqlRepository<Breed_Translated> { } public class Breed_TranslatedSqlRepository : RepositoryBase<Breed_Translated>, IBreed_TranslatedSqlRepository { public Breed_TranslatedSqlRepository(IDatabaseFactory databaseFactory) : base(databaseFactory) {} } BLL Repo: public IQueryable<Breed_Translated> QueryObjectGraph(Expression<Func<Breed_Translated, bool>> filter, params string[] children) { return _r.QueryObjectGraph(filter, children); } Controller: var breeds1 = _breedTranslatedRepository .QueryObjectGraph(b => b.Culture == culture, new string[] { "AnimalType_Breed" }) .ToList(); I can't get to Breed.AnimalType_Breed.AnimalTypeId ..I can drill as far as Breed.AnimalType_Breed then the intelisense expects an expression? Cues if any, DB Tables: bold is many-to-many Breed, Breed_Translated, AnimalType_Breed, AnimalType, ...

    Read the article

  • Error 3032 during EF 4.0 validation

    - by Mohammadreza
    Hi guys. I have a table that has a column called "rowguid" with default value of newguid(). After I delete the generated property in the Entity Framework 4.0 designer, whenever I try to build or validate the model I receive the following error message. Error 3023: Problem in mapping fragments starting at line 1460:Column People.rowguid in table People must be mapped: It has no default value and is not nullable. It's an obvious error message but the problem is that the column HAS default value. Does anyone knows what the problem is? Thanks.

    Read the article

  • EF 4.1 Code First Detaching Entity

    - by Nazaf
    I am trying to add an entity to the DB. Once I have added it, I want to detach it, so I can manipulate the object safely without making any changes to the DB. After calling context.SaveChanges() I do the following to detach the entity: // save context.Stories.Add(story); // attach tags. They already exists in the database foreach(var tag in story.Tags) context.Entry(tag).State = System.Data.EntityState.Unchanged; context.SaveChanges(); context.Entry(story).State = System.Data.EntityState.Detached; However, changing the entity state to DETACHED will remove all related entities associated with the my entity. Is there a way to stop this ? If I don't detach the entity, all my changes are sent to the DB next time I call context.SaveChanges() Thanks!!

    Read the article

  • Reduce the number of queries in EF

    - by Gio2k
    I have the following Model: Entities: Product (Contains basic data for products: price, etc) Attribute (Contains data for all possible optional attributes) ProductAttribute (Contains data for optional attributes of a product, eg. Color, Model, Size). ProductAttribute is essentially a many to many relationship with payload (ProductId, AttributeID, Value) And this piece of code: private static void ListAttributes(Product p) { p.ProductAttributes.Load(); foreach (var att in p.ProductAttributes) { att.Attribute.load(); Console.WriteLine("\tAttribute Name:{0} - Value {1}", att.Attribute.Name, att.AttributeValue); } } This piece of code will fire a query for each time the att.Attribute.Load() method is called in the foreach loop, only so i can get display the name of the attribute. I would like to fetch the Attribute.Name together with the query that fetches all attribute values, i.e. join ProductAttribute and Attribute. Is there any way to achieve this within my method?

    Read the article

  • EF Code First - Relationships

    - by CaffGeek
    I have these classes public class EntityBase : IEntity { public int Id { get; set; } public DateTime Created { get; set; } public string CreatedBy { get; set; } public DateTime Updated { get; set; } public string UpdatedBy { get; set; } } public class EftInterface : EntityBase { public string Name { get; set; } public Provider Provider { get; set; } public List<BusinessUnit> BusinessUnits { get; set; } } public class Provider : EntityBase, IEntity { public string Name { get; set; } public decimal DefaultDebitLimit { get; set; } public decimal DefaultCreditLimit { get; set; } public decimal TreasuryDebitLimit { get; set; } public decimal TreasuryCreditLimit { get; set; } } public class BusinessUnit : EntityBase { public string Name { get; set; } } An interface, is really a Provider, with a collection of Business Units. The issue is that while my db model ends up having a correct EftInterfaces table, with a FK to Provider_Id, the BusinessUnits table has a FK to EftInterface_Id. But, a BusinessUnit can be included in more than one EftInterface. I need a many to many relationship. A BusinessUnit can be part of many EftInterfaces, and an EftInterface can contain many BusinessUnits. How can I get CodeFirst to generate the many-to-many table?

    Read the article

  • LINQ EF not saving to database...

    - by Keith Barrows
    I guess this is a continuation of the last question I asked: http://stackoverflow.com/questions/2587542/bulk-insert-and-update-with-ado-net-entity-framework. I am not getting any errors while doing inserts yet no data is actually going into my DB. My DB is a SDF file (SQL CE). Any ideas what to check? My app.config looks like: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="Lab_Use_Billing.Properties.Settings.LabUseConnectionString" connectionString="Data Source=|DataDirectory|\Models\LabUse.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" /> <add name="LabUseEntities" connectionString="metadata=res://*/Models.LabUseEntities.csdl|res://*/Models.LabUseEntities.ssdl|res://*/Models.LabUseEntities.msl; provider=System.Data.SqlServerCe.3.5; provider connection string=&quot;Data Source=|DataDirectory|\Models\LabUse.sdf&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> </configuration> TIA

    Read the article

  • Linq to Entities (EF): How to get the value of a FK without doing the join

    - by Chu
    I'm using the Linq to Entities. I've got my main table, Employee setup with a field named vendorID. Vendor ID is a foreign key into the Vendors table. As it is right now, the Employee object does not directly expose the vendorID. Instead, I can only access it this way: var employee = (from e in context.Employees.Include("tbl_vendors") where e.employeeID = 1 select e).FirstOrDefault(); //this gets the vendor ID int vendorID = employee.tbl_vendors.vendorID; That is just fine and dandy, but it is extra work on the database because it is forcing a join where none is needed. Is there a way to get that key value without being forced to do a join to the tbl_vendors table?

    Read the article

  • Upgrading From EF 4x to 6 breaks everything

    - by dan h
    Attempted to upgrade my project from EF4 to EF6, I get build errors It appears that if i swap out the namespaces manually to include the entity.core it works, but if i change the .edmx file at all, the code reverts back to the old references and i have to manually edit the code generation files to include the update namespace references. I have attempted to "add code generation item" that does not resolve the issue at all. When i open the .edmx file in the IDE it shows me everything correctly.

    Read the article

  • EF Query with conditional include that uses Joins

    - by makerofthings7
    This is a follow up to another user's question. I have 5 tables CompanyDetail CompanyContacts FK to CompanyDetail CompanyContactsSecurity FK to CompanyContact UserDetail UserGroupMembership FK to UserDetail How do I return all companies and include the contacts in the same query? I would like to include companies that contain zero contacts. Companies have a 1 to many association to Contacts, however not every user is permitted to see every Contact. My goal is to get a list of every Company regardless of the count of Contacts, but include contact data. Right now I have this working query: var userGroupsQueryable = _entities.UserGroupMembership .Where(ug => ug.UserID == UserID) .Select(a => a.GroupMembership); var contactsGroupsQueryable = _entities.CompanyContactsSecurity;//.Where(c => c.CompanyID == companyID); /// OLD Query that shows permitted contacts /// ... I want to "use this query inside "listOfCompany" /// //var permittedContacts= from c in userGroupsQueryable //join p in contactsGroupsQueryable on c equals p.GroupID //select p; However this is inefficient when I need to get all contacts for all companies, since I use a For..Each loop and query each company individually and update my viewmodel. Question: How do I shoehorn the permittedContacts variable above and insert that into this query: var listOfCompany = from company in _entities.CompanyDetail.Include("CompanyContacts").Include("CompanyContactsSecurity") where company.CompanyContacts.Any( // Insert Query here.... // b => b.CompanyContactsSecurity.Join(/*inner*/,/*OuterKey*/,/*innerKey*/,/*ResultSelector*/) ) select company; My attempt at doing this resulted in: var listOfCompany = from company in _entities.CompanyDetail.Include("CompanyContacts").Include("CompanyContactsSecurity") where company.CompanyContacts.Any( // This is concept only... doesn't work... from grps in userGroupsQueryable join p in company.CompanyContactsSecurity on grps equals p.GroupID select p ) select company;

    Read the article

  • EF Stored Procedure Complex Type

    - by Web Dev
    I am using EF4. I am somewhat confused on on the Entity Framework Complex name. When I go to Functional Import of a Stored Procedure name and it ask me to type in the Complex name, is that supposed to be the name of of a class that can handle that output. For examle, say if my stored procedure returns FirstName, LastName. Is the Complex name supposed to be a class that can handle that output in this case PersonName? public class PersonName { public string FirstName {get; set;} public string LastName {get;set} }

    Read the article

  • EF Linq Product Sum when no records returned

    - by user1622713
    I’ve seen variations of this question all over the place but none of the answers work for me. Most of them are just trying to sum a single column too – nothing more complex such as the sum of a product as below: public double Total { get { return _Context.Sales.Where(t => t.Quantity > 0) .DefaultIfEmpty() .Sum(t => t.Quantity * t.Price); } } If no rows are returned I want to return zero. However if no rows are returned the .Sum() fails. There are various options of trying to insert Convert.ToDouble and using null coalesce operators, but they all still gave me errors. I’m sure I am missing a simple way to do this – any help greatly appreciated after too long banging head against google brick wall!

    Read the article

  • Please help translate this in linq to ef

    - by user3487644
    StringBuilder sb = new StringBuilder(); sb.AppendLine("SELECT"); sb.AppendLine(String.Format(" (SELECT TOP 1 CAST(ProspectID AS VARCHAR(5)) FROM Lead_Import_Fail Where ProspectID < {0} AND ProspectFullName = '{1}')", Convert.ToInt64(lead.LeadID), lead.Name)); sb.AppendLine(String.Format(", (SELECT TOP 1 CAST(ProspectID AS VARCHAR(5)) FROM Lead_Import_Fail Where ProspectID < {0} AND ProspectNRICPassport = '{1}')", Convert.ToInt64(lead.LeadID), lead.NRIC)); Thanks in advance.

    Read the article

  • Using Entity Framework (code first) migrations in production

    - by devdigital
    I'm just looking into using EF migrations for our project, and in particular for performing schema changes in production between releases. I can see that generating SQL (delta) script files is an option, but is there no way of running the migrations programmatically on app start up? Will I instead need to add each delta script to the solution and write my own framework to apply them in order (from the current version to the latest) on bootstrap?

    Read the article

  • How to implement table-per-concrete-type strategy using entity framework

    - by SDReyes
    Hello Guys! I'm mapping a set of tables that share a common set of fields: So as you can see I'm using a table-per-concrete-type strategy to map the inheritance. But... I have not could to relate them to an abstract type containing these common properties. It's possible to do it using EF? BONUS: The only non documented Entity Data Model Mapping Scenario is Table-per-concrete-type inheritance http://msdn.microsoft.com/en-us/library/cc716779.aspx : P

    Read the article

  • How to implement table-per-concrete-type using entity framework

    - by SDReyes
    Hello Guys! I'm mapping a set of tables that share a common set of fields: So as you can see I'm using a table-per-concrete-type strategy to map the inheritance. But... I have not could to relate them to an abstract type containing these common properties. It's possible to do it using EF? BONUS: The only non documented Entity Data Model Mapping Scenario is Table-per-concrete-type inheritance http://msdn.microsoft.com/en-us/library/cc716779.aspx : P

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >