[Bug] Association's
От: Holms США  
Дата: 18.11.10 17:58
Оценка:
Что-то ассоциации не работают как надо

LINQ
var f = (from project in ctx.Project
                where project.ProjectId == 1
                select project.Finances).FirstOrDefault();


foreach (ProjectFinance finance in f)
{
    Console.WriteLine(finance.OriginalBudget);
}


public partial class Project
{
    [Association(ThisKey = "ProjectId", OtherKey = "ProjectId", CanBeNull = true)] 
    public List<ProjectFinance> Finances;
}

[TableName(Name="Project")]
public partial class Project
{
    [Identity, PrimaryKey(1)] public int      ProjectId       { get; set; }
    [Nullable               ] public string   ProjectIdVisual { get; set; }
                                                        public string   Name            { get; set; }
                                                        public DateTime Created         { get; set; }
                                                        public DateTime LastChange      { get; set; }
                                                        public int      CategoryId      { get; set; }
    [Nullable               ] public int?     Department      { get; set; }
    [Nullable               ] public int?     ClientSite      { get; set; }
    [Nullable               ] public int?     Location        { get; set; }
    [Nullable               ] public int?     CostType        { get; set; }
    [Nullable               ] public string   Purpose         { get; set; }
    [Nullable               ] public int?     Phase           { get; set; }
    [Nullable               ] public int?     State           { get; set; }
    [Nullable               ] public string   ProjectUniqueId { get; set; }
}

[TableName(Name="ProjectFinance")]
public partial class ProjectFinance
{
    [Identity, PrimaryKey(1)] public int     ProjectFinanceId  { get; set; }
                                                        public int     ProjectId         { get; set; }
                                                        public string  PhaseName         { get; set; }
                                                        public decimal OriginalBudget    { get; set; }
                                                        public decimal CurrentBudget     { get; set; }
                                                        public decimal CommitedToDate    { get; set; }
                                                        public decimal TotalCostsToDate  { get; set; }
                                                        public decimal Contingency       { get; set; }
                                                        public decimal FinalForecastCost { get; set; }
}


падает с ошибкой

Expression of type 'MeditanoDataModel.ProjectFinance' cannot be used for return type 'System.Collections.Generic.List`1[MeditanoDataModel.ProjectFinance]'



Call Stack
>    BLToolkit.4.dll!BLToolkit.Data.Linq.ExpressionParser<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>.SetQuery(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.FullConditionalExpression}) Line 52    C#
     BLToolkit.4.dll!BLToolkit.Data.Linq.ExpressionParser<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>.Parse.AnonymousMethod__c(System.Linq.Expressions.Expression pi = {System.Linq.Expressions.MethodCallExpressionN}) Line 122    C#
     BLToolkit.4.dll!BLToolkit.Data.Linq.ExpressionHelper.Match<System.Linq.Expressions.Expression>(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.MethodCallExpressionN}, System.Func<System.Linq.Expressions.Expression,bool>[] matches = {System.Func<System.Linq.Expressions.Expression,bool>[4]}) Line 388 + 0xe bytes    C#
     BLToolkit.4.dll!BLToolkit.Data.Linq.ExpressionParser<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>.Parse(string contextID = "Sql", BLToolkit.Mapping.MappingSchema mappingSchema = {BLToolkit.Mapping.DefaultMappingSchema}, System.Func<BLToolkit.Data.Sql.SqlProvider.ISqlProvider> createSqlProvider = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Linq.Expressions.Expression expression = {System.Linq.Expressions.MethodCallExpressionN}, System.Linq.Expressions.ParameterExpression[] parameters = null) Line 85 + 0x188 bytes    C#
     BLToolkit.4.dll!BLToolkit.Data.Linq.ExpressionInfo<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>.GetExpressionInfo(BLToolkit.Data.Linq.IDataContextInfo dataContextInfo = {BLToolkit.Data.Linq.DataContextInfo}, System.Linq.Expressions.Expression expr = {System.Linq.Expressions.MethodCallExpressionN}) Line 58 + 0x93 bytes    C#
     BLToolkit.4.dll!BLToolkit.Data.Linq.Table<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>.GetExpressionInfo(System.Linq.Expressions.Expression expression = {System.Linq.Expressions.MethodCallExpressionN}, bool cache = false) Line 106 + 0x46 bytes    C#
     BLToolkit.4.dll!BLToolkit.Data.Linq.Table<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>.System.Linq.IQueryProvider.Execute<System.Collections.Generic.List<MeditanoDataModel.ProjectFinance>>(System.Linq.Expressions.Expression expression = {System.Linq.Expressions.MethodCallExpressionN}) Line 179 + 0xe bytes    C#
     [External Code]    
     TestCompiledQueies.exe!TestCompiledQueies.Program.Main(string[] args = {string[0]}) Line 23 + 0x275 bytes    C#
     [External Code]
... << RSDN@Home 1.2.0 alpha 4 rev. 1476>>
The life is relative and reversible.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.