entity-framework

EF4 two models one database, possible?

拈花ヽ惹草 提交于 2020-02-24 04:12:22
问题 I have been searching for this answer and can't seem to find anything, but with EF4 I want to create a base model and put in our 'foundation' and any new project we create if we need to add custom tables to that sites db is it possible to add a model with just those specific tables and link it to the model in our 'foundation' I can't seem to find a good resource on something like this and this seems to be like it would be a normal thing to have a reusable base model and a separate one for any

Include with FromSqlRaw and stored procedure in EF Core 3.1

百般思念 提交于 2020-02-23 10:40:30
问题 So here's the deal - I am currently using EF Core 3.1 and let's say I have an entity: public class Entity { public int Id { get; set; } public int AnotherEntityId { get; set; } public virtual AnotherEntity AnotherEntity { get; set; } } When I access the DbSet<Entity> Entities normal way, I include AnotherEntity like: _context.Entities.Include(e => e.AnotherEntity) and this works. Why wouldn't it, right? Then I go with: _context.Entities.FromSqlRaw("SELECT * FROM Entities").Include(e => e

Compare phone numbers without considering any format in Linq to entities and check performance as well

馋奶兔 提交于 2020-02-23 06:09:20
问题 I have to compare phone numbers in Linq to entities. I am using Regex so that I can compare only numbers while ignoring format. As we can not use Regex in where clause so I get list of phone numbers and then applied loop to compare the phone numbers. Here is the code: /// <summary> /// Check Phone number exist or Not /// </summary> /// <param name="accountNumber"></param> /// <returns></returns> public bool CheckPhoneNumberExist(string phoneNumber) { LP= new LPEntities(); // In order to

Compare phone numbers without considering any format in Linq to entities and check performance as well

泪湿孤枕 提交于 2020-02-23 06:07:23
问题 I have to compare phone numbers in Linq to entities. I am using Regex so that I can compare only numbers while ignoring format. As we can not use Regex in where clause so I get list of phone numbers and then applied loop to compare the phone numbers. Here is the code: /// <summary> /// Check Phone number exist or Not /// </summary> /// <param name="accountNumber"></param> /// <returns></returns> public bool CheckPhoneNumberExist(string phoneNumber) { LP= new LPEntities(); // In order to

Compare phone numbers without considering any format in Linq to entities and check performance as well

断了今生、忘了曾经 提交于 2020-02-23 06:06:57
问题 I have to compare phone numbers in Linq to entities. I am using Regex so that I can compare only numbers while ignoring format. As we can not use Regex in where clause so I get list of phone numbers and then applied loop to compare the phone numbers. Here is the code: /// <summary> /// Check Phone number exist or Not /// </summary> /// <param name="accountNumber"></param> /// <returns></returns> public bool CheckPhoneNumberExist(string phoneNumber) { LP= new LPEntities(); // In order to

EntityFramework Core - Copying an entity and placing it back into the database

≯℡__Kan透↙ 提交于 2020-02-21 11:02:11
问题 Is there a best practice for doing a copy of an entity, making some changes to it based on user input, and then re-inserting it into the database? Some other Stackoverflow threads have mentioned that EF will handle inserting new objects for you even if the same primary key exists in the database, but I'm not quite sure that's how EF Core is handling it. Whenever I try and copy an object I get an error of Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to

Entity Framework 6 - inheritance and navigation properties on base class

喜欢而已 提交于 2020-02-21 06:30:13
问题 I have a problem with navigation properties and inheritance. This is my problem: I have a base Person class and classes User and Worker which inherit from Person . On the DB level I'm using single table inheritance or table per hierarchy (TPH) inheritance. So there a single table with a discriminator column. Both User and Worker need to have a Company relation, so I would like to define it on the Person class. I define my model like this: [Table("mydb.person")] public abstract partial class

How can I map MS SQL datatype numeric(19, 0) to .NET type [closed]

女生的网名这么多〃 提交于 2020-02-20 09:24:46
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I am working on the mapping from MS SQL database to POCO classes: I have numeric(19, 0) , numeric(18, 0) , numeric(3, 0) , numeric(3, 0) . I am using the EF power tools to generate POCO and all map to decimal .NET C# Type . But I think it should map to BigInt , Int64 , Int32 , Int16 etc. 回答1: Here

How can I map MS SQL datatype numeric(19, 0) to .NET type [closed]

北慕城南 提交于 2020-02-20 09:24:19
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I am working on the mapping from MS SQL database to POCO classes: I have numeric(19, 0) , numeric(18, 0) , numeric(3, 0) , numeric(3, 0) . I am using the EF power tools to generate POCO and all map to decimal .NET C# Type . But I think it should map to BigInt , Int64 , Int32 , Int16 etc. 回答1: Here

WPF TreeView Binding [duplicate]

南楼画角 提交于 2020-02-20 07:37:26
问题 This question already has answers here : Closed 11 years ago . I've got a class with Parent and Children properties. ADO.NET Entity Framework Hierarchical Page Class http://img148.imageshack.us/img148/6802/edmxxe8.gif I want to display this hierarchy in a WPF treeview. Here's my XAML... <TreeView Margin="12" Name="TreeViewPages" ItemsSource="{Binding}"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Children}"> <TextBlock Text="{Binding Path=ShortTitle}" /> <