Пример #1
0
        private static CourseDto funcMain1(Course p2)
        {
            if (p2 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p2, typeof(CourseDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((CourseDto)cache);
                }
                CourseDto result = new CourseDto(p2.CourseId, p2.Title, p2.Credits, funcMain2(p2.Enrollments));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
Пример #2
0
        public static EnrollmentDto AdaptTo(this Enrollment p8, EnrollmentDto p9)
        {
            if (p8 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p8, typeof(EnrollmentDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((EnrollmentDto)cache);
                }
                EnrollmentDto result = new EnrollmentDto(p8.EnrollmentId, p8.CourseId, p8.StudentId, p8.Grade, funcMain7(p8.Course), funcMain10(p8.Student));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
Пример #3
0
        private static EnrollmentDto funcMain12(Enrollment p15)
        {
            if (p15 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p15, typeof(EnrollmentDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((EnrollmentDto)cache);
                }
                EnrollmentDto result = new EnrollmentDto(p15.EnrollmentId, p15.CourseId, p15.StudentId, p15.Grade, null, null);
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
Пример #4
0
        private static StudentDto funcMain10(Student p13)
        {
            if (p13 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p13, typeof(StudentDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((StudentDto)cache);
                }
                StudentDto result = new StudentDto(p13.Id, p13.LastName, p13.FirstMidName, p13.EnrollmentDate, funcMain11(p13.Enrollments));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
Пример #5
0
        public static StudentDto AdaptTo(this Student p6, StudentDto p7)
        {
            if (p6 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p6, typeof(StudentDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((StudentDto)cache);
                }
                StudentDto result = new StudentDto(p6.Id, p6.LastName, p6.FirstMidName, p6.EnrollmentDate, funcMain5(p6.Enrollments));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
Пример #6
0
        public static CourseDto AdaptTo(this Course p6, CourseDto p7)
        {
            if (p6 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p6, typeof(CourseDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((CourseDto)cache);
                }
                CourseDto result = new CourseDto(p6.CourseId, p6.Title, p6.Credits, funcMain5(p6.Enrollments));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
Пример #7
0
        public static TResult GetOrAddMapReference <TResult>(ReferenceTuple key, Func <ReferenceTuple, TResult> mapFn) where TResult : notnull
        {
            using var context = new MapContextScope();
            var dict = context.Context.References;

            if (!dict.TryGetValue(key, out var reference))
            {
                dict[key] = reference = mapFn(key);
            }
            return((TResult)reference);
        }