I would like to have a [Field] with a [FieldMapping] on for a foreign key, both on the column name and the Entity association...Is this possible? ie.
Is this possible? Domain.Build throws an exception when I do this. I would like this specifically for the situation of a join that doesn't have a reverse mapped association:
Also, can I have multiple associations mapped on a field like:
Thank you. Thanks. Updated at 25.02.2010 23:02:45Domain.Build throws an exception when I put FieldMappingAttribute of "CompanyID" on Field Company and Field CompanyID...I'm ok with joining on Company.ID...but it won't go and fetch the whole related row, will it? Also, I'm getting closer I think (the domain.Build takes longer)...but now I have the following exception calling domain.Build(config)
Updated at 26.02.2010 2:00:16I'm running on a an database that I've never touched before with about 600 tables. I wrote/hacked a T4 script to transform an existing linq2sql dbml file for this DB schema into DataObjects attributed classes. I'm running upgrademode as Validate only. I'll get you a full schema sample shortly, in case the above doesn't give enough info. Also...if DataObjects needs to create custom temp tables, is there a way to have it do so in memory only? Or on a different DB server? Access to the DB I want to query should be read-only. Thanks. Updated at 26.02.2010 14:36:07I'm certainly open to other suggestions on how to implement this but what it comes down to is that it's not "my" database. In other words, I can't touch it...or do anything except read from it. I have a database that's mine that I can do whatever I want with on the same LAN on a different SQL Server...or maybe I could even make a second instance of SQL Server on the same physical box...but I can't alter their database. I'd really like to leverage your LINQ support, but I don't think there is any flexibility on this requirement. Thanks. Updated at 26.02.2010 17:12:37Ok, that's awesome, thanks. I'll use Legacy mode instead of Validate. I may be able to get around the access to tempdb...I was just under the misimpression that tables also needed to be created in the target DB too... Working on getting you the schema for my error... Updated at 26.02.2010 18:08:10The schema export wizard is giving me a hard time for some reason...not sure why. But I loaded your pdbs and captured the following: index.CreateIndexColumn(table.GetColumn(columnId), !reader.GetBoolean(13)); is the source of the exception, in ExtractIndexes. columnId = 14 query = "select t.schema_id, t.object_id, t.type, i.index_id, i.name, i.type, i.is_primary_key, i.is_unique, i.is_unique_constraint, i.fill_factor, ic.column_id, 0, ic.key_ordinal, ic.is_descending_key, ic.is_included_column, NULL, NULL from sys.indexes i inner join (select schema_id, object_id, 0 as type from sys.tables union select schema_id, object_id, 1 as type from sys.views) as t on i.object_id = t.object_id inner join sys.index_columns ic on i.object_id = ic.object_id and i.index_id = ic.index_id where i.type < 3 and not (ic.key_ordinal = 0 and ic.is_included_column = 0) and schema_id = 1 order by t.schema_id, t.object_id, i.index_id, ic.is_included_column, ic.key_ordinal" Debug logs around the exception...it looks like a replication table....I'll try removing it from my model...please let me know if this helps...thanks.:
More: It's a view now that's causing the problem: return view.ViewColumns[dbColumnIndex]; dbColumnIndex=14 vw_pr_company_focus_element is the object name...so it's a view. Does DO not support views? Updated at 27.02.2010 22:14:52I'm sure it's an overstatement that implementing stored proc support is pretty simple, but fortunately I need only to support SQL server for now.... I already have my own wrapper QueryProvider, IQueryable implementation, and fast serializer (with what I think you call O2O mapping) for WCF/Silverlight/POCO support, and my dbml file already generates the class definitions for the sotred proc and view result sets. So, I'm thinking all I really need to do is make my expression visitor on my server use SqlClient to execute queries against stored procs and views, read them out into their class equivalents and then swap them back into the expression tree as constants. Sorry if that was a little unclear. Please let me know if you need any additional info from me to help get the issue (index out of range) resolved with extracting the metadata from the SQL schema. Thank you. Updated at 01.03.2010 16:01:59It's failing at the following line in SqlModelConverter
because sqlValueType is smalldatetime and Type is Unknown. If that sheds any light on it, I'd be more than happy to make the code fix myself if you could point me in the right direction. Thanks. Updated at 02.03.2010 17:53:17Hi, Sorry for the confusion. I tried to generate scripts for my schema to email to you...but I got a strange error from SQL Management Studio indicating something to the effect of my schema is invalid! It's not my database, so I have no idea how this could happen... Anyway, I restored a fresh copy of the DB and ran the export again and I was able to generate scripts successfuly...and I also got past that error in DO....so really I don't know what happened. I'm now up to a much more promising error (I hope). Upon building the domain, I'm told (SchemaSynchronizationException): Legacy schema is not compatible ( (can't change type of column 'Tables/tbl_pr_ben_fund_company_holding/Columns/holding_dttm')).
Interesting thing is my model has this listed as a DateTime field...SQL has it listed as a smalldatetime field (the same time that I think was giving problems before...). It's SQL Server 2005. I'm emailing you my schema, model, dbml file, and T4 script to the address provided. Additionally, and more importantly, I can't rule out the fact that someone may make changes to this DB without my model getting updated. Is there a way to make DO validate the SQL schema matches the class schema on demand, not all on Domain.Build(), in Legacy mode? This would be critical for me, as all of my query support will break all the time if someone changes any table of the 500ish in the DB... I would like to still be able to query as long as the tables I'm querying are still valid... This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by JeffN. |
Alex (Xtensive) wrote:> I would like to have a [Field] with a [FieldMapping] on for a foreign key, both on the column name and the Entity association...Is this possible? We have the following code in tests:
So this is definitely possible. But you shouldn't (and can't) split declaration of field and the association. > Also, can I have multiple associations mapped on a field like... This is not possible. What is your actual purpose? Having an association (reference field), you can:
Alex (Xtensive) wrote:Btw, your query with join must look like (see all 3 options):
All these queries lead to absolutely the same SQL query in the end. Alex (Xtensive) wrote:> Domain.Build throws an exception when I put FieldMappingAttribute of "CompanyID" on Field Company and Field CompanyID... The exception you get is actually thrown from schema extractor, so it must not be related to the original case. Could you try to create some simple schema in the same database in Validate (it will fail, but with another exception) or Recreate (will destroy all the data, but must not lead to failure) UpgradeMode? If it will fail with the same exception, can you send us a backup of the database you use, or just its schema w/o data? > I'm ok with joining on Company.ID...but it won't go and fetch the whole related row, will it? No, it won't. Alex (Xtensive) wrote:> Also...if DataObjects needs to create custom temp tables, is there a way to have it do so in memory only? In-memory - no. We use them only to transmit the data to SQL Server, but SQL Server does not understand our in-memory tables :( In fact, in-memory tables are useless with SQL Server provider. > Or on a different DB server? No, currently this is impossible, although this is possible in general. If this is really important for you, we can think about implementing it. But note:
Alex (Xtensive) wrote:Temporary tables aren't actually created @ your database. They always created in tembdb. So you won't modify the original database. Btw:
Alex (Xtensive) wrote:If you use any upgrade mode except DomainUpgradeMode.Legacy:
If you use DomainUpgradeMode.Legacy:
Legacy upgrade mode was is actually designed to cover nearly your cases:
Further this must evolve to full support of ActiveRecord pattern:
Alex (Xtensive) wrote:> Does DO not support views? Yes, it does not allow to map entities to them, but it should behave properly while extracting the info about them. We'll try to isolate the problem related to view info extraction tomorrow. > Also, stored proc resultsets would be a nice to have. The same - DO does not support mapping to stored procedures :( > It's pretty easy to implement myself... and I'll need to, but linq to sql does it. I fear it won't be a piece of cake, especially if you need database-independent solution there. If you'll deal just with SQL Server, using LINQ to SQL could really help here. In short, I've made a conclusion full support of various mapping scenarios for legacy databases is really important. Currently we have the following lacks:
Last two options must not be really complex for us (we already discussed this today) - most likely in all the cases here we must return DTOs, but mapping of query result and arbitrary DTOs is already fully supported (this is the most complex part). So we must mainly make all the decisions about the API, and this is actually a hard part:
I'm not sure if we can prioritize this - I feel we must implement already planned features first (security, better WPF\WF\ASP.NET MVC support, VS2010 & .NET 4, PostSharp 2.0), but I'd like to eliminate all really blocking issues like problem with view info extractions ASAP. Alex (Xtensive) wrote:> If I can get this working, I'll give you my T4 script that transforms the dbml file (not that it was that much work...) That would be cool, thanks :) Denis Krjuchkov (Xtensive) wrote:Hello, JeffN. I have some questions regarding your issue with smalldatetime. Are you using SQL Server 2005 or 2008? Are you still using Legacy upgrade mode? Can you provide full stack trace? It will also be very helpful, if you provide persistent class definition and corresponding table definition. If you don't want to publish your code here, send me a email to denis.krjuchkov at dataobjects dot net. Thanks for helping improving DataObjects.Net :wink: Denis Krjuchkov (Xtensive) wrote:
Alex (Xtensive) wrote:Just talked with Denis, few conclusions:
Alex Kofman wrote:
Denis Krjuchkov (Xtensive) wrote:No, it does not. As Alex Kofman already suggested, you can monitor progress of this issue here. http://code.google.com/p/dataobjectsdot ... ail?id=613 smalldatetime columns are now handled properly. JeffN wrote: Great! Thank you. Would you please post something here when the new domain upgrade mode without validation is in place? Or is there an update list I can check to see when this has been released? It's a blocking issue for me. Thanks again. I'll update v4.2 installer today. There were no any critical changes except such fixes, so this must be ok. v4.2 installers were updated yesterday, all the fixes are there. JeffN wrote: Does that include the skip validation for legacy mode?? True. We'll try to implement this by the end of this week. JeffN wrote: Hi guys, Any update of this? Thanks. Hello Jeff, The feature is already implemented and is on the testing stage, so it will be included into upcoming nightly build soon. I extracted a part of this topic to a separate one: viewtopic.php?f=29&t=5797 For now nothing is necessary: we're quite busy with release, so AFAIK, no one was able to test this on weekend. I hope tomorrow we'll do this, and if this won't be reprodicable @ our tests, I'll ask you to send your database schema (w\o data). Let us try to fix this tomorrow - likely, this will help to resolve the issue. I can't help with this right now - it's a deep night here (almost 4am). Denis, see viewtopic.php?f=29&t=5784&p=13987#p13962 Full stack trace is here. Err... True again, the issues are diffrent. I imagined there is a single one :) Hello, Jeffrey. I've recieved your mail. I'll work on this issue today. Thanks for cooperation. Created issue: http://code.google.com/p/dataobjectsdot ... ail?id=613 JeffN wrote: Does DO need to create any tables in the mapped DB? The How It Works section which declares MyEntity includes a picture of SQL Server Management Studio with dbo.Assembly, dbo.Int32-Generator, and dbo.Type. Are these created by DO? Thanks. JeffN wrote: If I can get this working, I'll give you my T4 script that transforms the dbml file (not that it was that much work...) JeffN wrote: Also, stored proc resultsets would be a nice to have. It's pretty easy to implement myself...and I'll need to, but linq to sql does it. |